On Thu, 19 Aug 2004 21:52:27 +0200, captain biceps <(E-Mail Removed)> wrote:
> But now, my tcp windows size seems to be "too small" to handle all the
> 256ko no ? What happens is this case ? I mean, the recv function
> (internally) will fetch my data in two passes ?
You will get the data in whatever size chunks you get it in. It will
take however many passes it takes. The TCP window size doesn't
guarantee anything in that regard.
In general you should not ever assume that TCP will deliver data in any
particular chunk size, because sooner rather than later your assumption
will be wrong. It is a stream protocol, not a datagram protocol. Think
of TCP as a serial port with unknown and jittery timing.
What you need to do is create some way of telling when you have received
a complete message. Some options are a header with a byte count, a
record separator (e.g. newline), or inserting special data of some kind
in the stream. However you do it the point is that you need to be able
to find the start and end of a message independent of how many times you
have to call read() to get the whole thing.
Or you could use UDP with your own retry mechanism.
--
-| Bob Hauck
-| To Whom You Are Speaking
-|
http://www.haucks.org/