When * exactly * is a socket ready to write?

When an application has a huge amount of data (400M) to write to a non-blocking socket, write()returns EWOULDBLOCKor EAGAINwhen the send buffer is full.

When socket (e) is polled, I sometimes see a notification of readiness for recording, when sometimes there is 7M space in the send buffer, sometimes 20M and at other times 1M. The difference in the delay between write callbacks is huge: from milliseconds to tens of seconds!

So my question is when exactly does the kernel run the ready-to-write socket socket? What affects the start of recording ready? Obviously, this does not work as soon as 1B is written to the wire.

Any help would be appreciated!

I use:

Ubuntu 12.04 LTS

Kernel 3.8.0-39-common

Arch: x86_64

EDIT: Sockets in this context are TCP / IP sockets.

+4
source share

Source: https://habr.com/ru/post/1539795/


All Articles