Delay with TCP ? Use TCP_NODELAY

When you have a TCP server dans client and you send small data you can have delay between sending and receiving data. This Is because TCP uses Nagle’s algorithm by default.

Nagle’s algorithm collect small data and send them all at once, consequently you can have a delay between you call the method send() and the data are really sent.

If you have this delay and wish to remove it, deactivate the Nagle’s algorithm. You can deactivate it on server side and client side.

On Python :

socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

On Java/Android :


There is also TCP_CORK, I didn’t enable it, consequently I have no experience with it. You can check this web page to get more information :


No responses yet

Laisser un commentaire