2

I have a server and many client implemented in Python, talking over sockets. I want message sent from both sides to be rushed immediately to the other side.

I found this article which talks about calling .flush() on the socket. However, I don't see any flush() api in the python doc here.

Here is a stackoverflow answer regarding the similar question.

  • It suggests a naive option of closing the socket. However, I want to keep one connection and not re-connect again and again(to avoid complexity of code and useless burden on system.)
  • It has another answer suggesting to convert the socket to a textfile like object and then call flush on it. However, comments there raise question on its credibility and it is for python 3 and is not accepted answer as well.

I do NOT necessarily need TCP socket, UDP is fine for me as well. But the only thing I want is that data should be sent immediately. Any suggestions for achieving that? I would prefer clean solution, however, hacks are welcome as well.

PHcoDer
  • 1,166
  • 10
  • 23
  • What library are you using? There should not be a need to flush data from a buffer. – roganjosh Nov 27 '18 at 20:36
  • You could try ZMQ or kafka from what I understand of your question. – roganjosh Nov 27 '18 at 20:37
  • @roganjosh I am using python's module socket(import socket). What do you mean by no need to flush data? My messages are of size 25 B or so. Won't TCP wait for certain fixed time to try to accumulate more data? – PHcoDer Nov 27 '18 at 20:42
  • I actually have never used the base library for sockets. I have a hunch you would benefit from Zero MQ but it's hard to say – roganjosh Nov 27 '18 at 20:44

0 Answers0