TCP packet size?

Walter Hofmann wh at msgto.com
Mon Jun 26 16:14:07 EDT 2000


On Thu, 15 Jun 2000 01:53:15 -0500, chris <chris at rpgarchive.com> wrote:
>
>
>--------------6576511AB77059DEC203AB93
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>Is there a way to ensure or predict packet size when using TCP?  I'm
>developing a Multi-user application that functions much like a
>muli-player game.  The applications are sharing xml data.  The xml data
>can get very big 3000-6000 bytes.  Unfortunately, when the size of the
>network message gets over about 2000, its to get broken up into smaller
>packets.  So, when I send a 3000 byte message it gets cut up into 2-3
>packets.  Anther problem I get is when I send two small messages back to
>back, they are sometimes received together.  Is there something I'm
>missing here?

No. That's the way TCP works. It gives you a "stream" of data. Use UDP
if you want to have packets (like most games do, AFAIK), but be prepared
to handle lost or duplicate packets. If you send UDP packets larger that
the MTU they will get fragmented, which will harm performance.

Using TCP you have to add message headers or an "end of record" string 
so that you know when to issue another "read" to get the rest of the
packet.

Walter


-- 
begin  LOVE-LETTER-FOR-YOU.txt.vbs
Hi! I'm a signature-virus. Distribute me!
end



More information about the Python-list mailing list