Python Socket Flush

后端 未结 4 2204
逝去的感伤
逝去的感伤 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条回答
  •  猫巷女王i
    2020-11-30 13:23

    This is a common question about TCP protocol. TCP itself has no way to send data in specific chunks. It's designed only for sending stream of data. If you need such functionality, you should implement it yourself. For example, send your chunks in separate lines or first send chunk size and then the chunk itself.

    In most cases, you don't need to care about the Naggle algorithm. This algorithm is better described by the name TCP_NODELAY. If you disable it, you may achieve smaller delays for small chunks but lower speed for large chunks at the same time.

提交回复
热议问题