Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 1996 18:08:23 PST
From:      Bill Fenner <fenner@parc.xerox.com>
To:        "Marc G. Fournier" <scrappy@ki.net>
Cc:        John Polstra <jdp@polstra.com>, hackers@freebsd.org
Subject:   Re: Sockets question... 
Message-ID:  <96Nov14.180824pst.177557@crevenia.parc.xerox.com>
In-Reply-To: Your message of "Thu, 14 Nov 96 11:44:03 PST." <Pine.NEB.3.95.961114144229.5812I-100000@quagmire.ki.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <Pine.NEB.3.95.961114144229.5812I-100000@quagmire.ki.net> you write
:
>	At 1024, data seems to be lost.  I send 1023 bytes across, and
>receive 4...send 1023, receive 907...I send across 100 packets, receive
>2...

TCP is not a record-oriented protocol, and will buffer up (or re-packetize
however it wants) any data that you give it.  Therefore, you have to be
prepared to read whatever size it wants to give you, and your application
has to be able to put it back together into what it wants.  Your data will
all get there, eventually.

>	As soon as I go to 512 or 80 byte writes, I can pound at it 
>repeatedly and get the complete image across every time, no errors.

Depending on the verison of FreeBSD, 512 bytes could be the TCP MSS,
so every time you write 512 bytes TCP realizes it has a whole packet
to send and sends it.  This could be different depending on the version
of FreeBSD and the MTU of the path, among other things.  I don't explicitly
know why 80 "works", but perhaps there is a threshold of "small" writes
that TCP will write immediately.

These are not behaviors you can depend on.  The MSS could be different
depending on who you are talking to, and the "small" is just a guess on
my part anyway.  What you need to do is write all your data to the network,
and not count on it arriving in the same sized chunks as you wrote it.
But it will all arrive.

  Bill



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?96Nov14.180824pst.177557>