Assume you have a client application which is known to connect to a given IP, and send a fixed size message (of size X = ~dozen bytes) upon connection, and wait for a reply.
If you're writing a server, can you guarantee that the first (non-EAGAIN) call to read() (assuming no errors) on the (non-blocking) socket after the accept() will return X?
My understanding is that TCP/IP is a streaming protocol, so that isn't guaranteed, but it might be true in practice, since such a small packet isn't likely (possible?) to be split during transmission.
sleep
for thread synchronization. It might work in practice, but it's still very wrong and might bite you once circumstances change.