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.