'How to enable python socket tcp flag PSH manually?

TCP merges some aligned packets and sends them together, but in my project, I wanna send packets instantly when I use socket.send() without filling the buffer. I have set TCP_NODELAY like below

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.setsockopt(socket.IPPROTO_TCP,socket.TCP_NODELAY, True)

But packets are also merged. I think setting PSH to 1 can solve this problem easily, so how to enable python socket TCP flag PSH=1 manually? I hope that every socket.send() creates a packet in the network. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source