Hi, > - OnDataAvailable event is triggered continuously (close to 14000 > times per second)
Do you call the message pump from OnDataAvailable, directly or indirectly (i.e. Application.ProcessMessages, any Showmessage() or a VCL-dialog)? -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Merijn Bosma wrote: > Merijn Bosma wrote: > > Hello, > > Yesterday evening we've found out that this problem still occurs, even > with wsoNoReceiveLoop set. > > The symptoms are the same: > - OnDataAvailable event is triggered continuously (close to 14000 > times per second) > - ReceiveStr() is called every time, returning no data > - Error is always 0 in the events > - The event keeps being triggered until we shut down the application. > > This is not a high speed stream, we sent only control data, so approx > up to 100 bytes every few seconds. > > I'm I doing something stupid or is there something else going wrong > here? If it's not me, is there any way for to determine whether this > is a problem with ICS, or with the Windows call stack itself? > >> Francois PIETTE wrote: >> >>>>> One possible explanation were that anytime OnDataAvailable >>>>> returns, just a few _new_ bytes are available in winsock buffer. >>>>> Could be possible due to the background thread winsock creates >>>>> internally with non-blocking sockets, though I'm not aware of how >>>>> winsock works under the hood. >>>>> >>>>> >>>> When in this situation, we got a few hundred calls a second, for an >>>> unlimited time, where normally it's one every few seconds. >>>> I agree with you, it could be a possible cause, but very unlikely. >>>> >>>> >>> Do you receive data each time you call ReceiveStr ? If yes, then >>> probably you have a fast network, and your application becomes CPU >>> bound. >>> >>> >> That's the thing, I don't receive any data. At least not using >> ReceiveStr() >> >>> btw: Since you don't use line mode, I strongly suggest you avoid >>> ReceiveStr and instead use Receive with a fixed buffer. Calling >>> ReceiveStr will force the runtime to create new string and copy >>> data into it, and probably youthen copy data elsewhere for >>> processing. All this is very CPU intensive. >>> >>> The best way to design a high performance application is to use a >>> fixed buffer (which may be dynamically allocated but not each time >>> you receive data). And use the buffer as close as possible of the >>> processing each time you copy data, each time you consume CPU and >>> memory for nothing. >>> >>> -- >>> [EMAIL PROTECTED] >>> The author of the freeware multi-tier middleware MidWare >>> The author of the freeware Internet Component Suite (ICS) >>> http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be