I use tcp for so many small items, should I turn off the Nagle algorithm? (People also know this as TCP_NODELAY)

I redid this post because my choice of name was terrible, sorry for that. My new message can be found here: After sending a large amount, my call to send () causes my program to stop completely. How is this possible?

Thanks to everyone. The problem was that the clients are actually bots and they never read from the connections. (Feeling stupid)

+5
source share
3 answers

TCP_NODELAYthe latency of small packets from sender to recipient can help, but the description you provided in different directions. I can imagine the following:

  • Sending more data than the receivers actually consume - this ultimately overflows the sender buffer ( SO_SNDBUF) and causes the server process to appear “stuck” in the system call send(2). At this point, the kernel waits for the other end to confirm some outstanding data, but the receiver does not expect it, so it does not recv(2).

There are probably other explanations, but it's hard to say without seeing the code.

+4
source

send() TCP, , , , , , . , recv() .

+4

Nagle " ", . , - .

.


.

, . - .

, , 23- , . , , .

If this is really the culprit, the solution would be some asynchronous communication, such as the Boost Asio library.

+2
source

All Articles