> WaitingData(Ex) is for me a very important function as it is also used in > TUDPBlockSocket. > I have for example, 40 hosts that send UDP datagrams of constant length > (10byte) asynchronosly to my application. > In a repeat..until block I loop through all the 40 UDP sockets. > If WaitingData<10 then I loop to the next. If WaitingDate=10 then I use one > of the recv.. functions with 10ms timeout to get the data and process it. > This loop should be done in less than 1ms.
You need UDP server for this. Simple loop in the thread: while not terminated do begin s := RecvPacket(500); if s <> '' then begin //do something with datagram end; end; This code is fast, consume 0% CPU, datagram are processed as soon as possible. And can process datagram with any size. It is very easy. Just you can wait max. 500ms when you terminating the thread. As I said before, Waitingdata is not needed when you are using receive functions with timeout. It is just code waste. > But when I use the recv(1).. function without WaitingData and only a timeout > (let us say 1ms) then I would lose 40ms when no data is received in the > loop? Why? It is exaclty same! Timeout in recv functions is implemented by Waitingdata call. -- Lukas Gebauer. http://synapse.ararat.cz/ - Ararat Synapse - TCP/IP Lib. https://www.geoget.cz/ - Geocaching solution _______________________________________________ synalist-public mailing list synalist-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synalist-public