TCP packet size?

Richard Brodie R.Brodie at rl.ac.uk
Wed Jun 14 08:10:24 EDT 2000


"chris" <chris at rpgarchive.com> wrote in message news:3948AC51.98E5EAEC at rpgarchive.com...

>The messages just aren't reassembled the way I thought TCP worked.
>I'm hoping to find a way to received one message at a time in its entirety,
>or determine the start and end of my messages

Sadly, it's supposed to work like that. TCP is a stream protocol; there is no concept
of a packet or message. The data stream comes out like a ticker-tape; if it stops
mid-message and carries on, or aggregates two messages, that's the programmer's
problem.

Now, one might think that it would be useful to have a protocol that allowed
arbitrary length messages to be sent and received atomically. TCP doesn't
do that. Easy to implement, harder to program for: it's the Unix way ;)

Everyone programming to the TCP/sockets API gets burnt sooner or later
by this. Curse three times, dance round the room widdershins, then put
a data length field in your message header. Check Stevens or any other
decent introduction to socket prograaming for details.





More information about the Python-list mailing list