From: Dominik Werder Date: 2003-05-16T23:11:07+09:00 Subject: Re: TCP Sockets > Sure, using the method that Nobu proposes you might be able to tell that > there are exactly 99 bytes sitting in the socket buffer right now. > > But how do you know that 99 bytes is a whole request? Maybe the whole > request is 138 bytes, but because the message is sent in TCP chunks, the > first read() returned 99 bytes, and the next read later returns 39 bytes. > Or > maybe it's two requests of 69 bytes each; the first read() returns the > whole > first request plus 30 bytes of the second request, and the the second > read() > returns the remaining 39 bytes. This is not the problem: If the request is not complete in one packet, the rest comes with the following packet. But if the request does not come at all cause 99 bytes are not enough, then I got a problem. Think about my software as an TCP/IP router. The TCP/IP router doesn't need to have knowledge of the protocol either. > They'll have a separate TCP connection for each peer, and process > messages > from each stream independently. Since you are parsing all the incoming > messages, you know where the message boundaries are. Does they also have one thread per TCP connection? thanks! Dominik