05-24-2007 03:45 PM
05-29-2007 08:15 AM
05-30-2007 01:14 PM
05-30-2007 04:56 PM
ioctrlsocket() called for FIONREAD will return the number of bytes available. This can be used in a loop to check if data is available without blocking the thread. And alternative is to use something like an async timer or a separate thread to monitor the availability of udp data. The thread would pull data from the udp socket and place it into a ThreadSafeQueue. The TSQ can be polled by the main thread to determine when data is available or a callback can be generated directly by the TSQ.
A warning about FIONREAD, do not expect all of your data to arrive at one time. UPD can split data across packets which leads to issues if poll for a specific byte count with FIONREAD. This even has an entry on the "Winsock Lame List."
05-31-2007 04:17 AM