Python Socket Flush

后端 未结 4 2177
逝去的感伤
逝去的感伤 2020-11-30 12:53

I am trying to make sure that every time I call the socket.send function my buffer is sent (flushed) to my server (which is in C using unix socket).

From my understa

4条回答
  •  無奈伤痛
    2020-11-30 13:32

    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.

提交回复
热议问题