> Can OnDataAvailable be called while it is > already running? > And if yes, how to prevent this? Is using critical > sections a good idea here?
You must avoid having the events reentered. To avoid this, you simply have to _not_ call any form of the message pump from the events. The message pump is ProcessMessages, any modal form, GetMessage/DispatchMessage and the likes. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be ----- Original Message ----- From: "Markus Humm" <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Thursday, August 31, 2006 8:20 PM Subject: [twsocket] OnDataAvailable and reetrancy > Hello, > > I've a server and a client app. which communicate through a TCP based > protocoll I designed. > > The server get's requests which in OnDataAvailable are received into a > 1500 Byte sized array (most time the app. will run on a LAN) whose > contents is copied into a larger buffer then since the request could be > fragmented. > > The larger buffer is processed within the context of OnDataAvailable. > If I send requests manually via clicking on a button in the client all > works well, but not if the client sends say 1.000 requests in a loop. > > The server gets out of sync then because the buffer contains garbage > now. But where does it come? Can OnDataAvailable be called while it is > already running? And if yes, how to prevent this? Is using critical > sections a good idea here? > > The processing of the larger puffer is to check validity of the request > and extract the real request out of my data format. The real request is > appended to a queue then which gets processed by a seperate thread. > > Greetings > > Markus > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be