If you are confident that the network and the client are reliable, then the problem is more straightforward.
When the client opens a connection, sends as all the data it's going to send in short order, and then closes the connection, the server will hear the close and will know that is the end of the data. sysread will return zero, indicating "eof" -- it will not block if everything has been read and the far end has closed their end of the connection. You don't need the timeout (whose purpose would be to detect some failure such that packets stop arriving).
If things really are this simple, it would be easier to use a single read (assuming you know that the maximum amount data to be received) which will return once it has read everything sent and the far end has closed.
In reply to Re^6: sysread and syswrite in tcp sockets
by gone2015
in thread sysread and syswrite in tcp sockets
by rustybar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |