From: Aredridel Date: 2003-05-17T00:29:08+09:00 Subject: Re: TCP Sockets On Fri, 2003-05-16 at 08:11, Dominik Werder wrote: > > 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. It doesn't need knowledge of the application protocol, but it needs to know -all- about TCP/IP -- it needs the headers for every packet -- source, destination, flags, window, mss, length. Once you're at the application (socket) level, you have buffers to deal with -- you don't know whether the 99 bytes was 1, 2 or 3 packets at all, unless you know how big the chunks the sender sends are.