Python Socket Flush

后端 未结 4 2208
逝去的感伤
逝去的感伤 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:33

    The only way I got a flush to work (back to a C client) was to use:

    my_writer_obj = mysock.makefile(mode='w', ...)
    my_writer_obj.write('my stuff')
    my_writer_obj.flush()
    

    The big advantage is that my_writer_obj defaults to text mode, so no more byte translation.

    creating a reader object did not go as smoothly, but I did not need a flush on that side.

提交回复
热议问题