Python Socket Flush

TCP does not provide any kind of guaranteed “packet” sending to the other end. You are sending data as fast as you can, and TCP is helpfully batching up the data into as much as it can send at once. Your server is receiving data 4096 bytes at a time, probably because that’s what it asked for (in a recv() call).

TCP is a stream protocol and therefore you will have to implement some kind of framing yourself. There are no built-in message boundaries.

Leave a Comment