Jake Traynham wrote: > So, it seems that for every time ASyncReceive looped, there would > still be a message (FD_Read??) being put in the queue to call it > again, which would call my DataAvailable event again, but there > wouldn't be any data to read because ASyncReceive had already looped > to get all the data.
That's correct, it's the call to WSocket_Synchronized_ioctlsocket() with option FIONREAD that causes winsock to send the extra FD_READ message. So nothing is corrupted, simply add wsoNoReceiveLoop to the options to get rid of that behaviour. Winsock will always send subsequent FD_Read messages after any call to one of the receive functions if there is still data available. > Should > there have only been one FD_Read in the queue initially which would > start the ASyncReceive loop but some how the queue is getting > corrupted (by some call to ProcessMessages maybe) causing it to > respond to the FD_Read more than once. See above. > Or should there be an FD_Read > for every block of data coming from the server, and if that's the > case, why does ASyncReceive loop? Because if there is an FD_Read for > every block of data, then ASyncReceive and any DataAvailable events > would be called multiple times. There is no relationship to the amount of data, there should be one FD_Read message as long as data is available in winsock's receive buffer. Looping in ASyncReceive is required before closing the socket in order to not miss any pending data. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- 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
