Skip to main content

INITIAL_TCP_SOCKET_READINESS

Constant INITIAL_TCP_SOCKET_READINESS 

Source
const INITIAL_TCP_SOCKET_READINESS: Readiness;
Expand description

On Linux a TCP socket is initally in the TCP_CLOSE state: See https://github.com/torvalds/linux/blob/cee9395/net/core/sock.c#L3753 For a socket in this state, (E)POLLHUP is reported: See https://github.com/torvalds/linux/blob/980a813/net/ipv4/tcp.c#L581-L582 Additionally, because the write buffer is initially empty and the socket is not shut down, (E)POLLOUT is also reported for freshly created TCP sockets: See https://github.com/torvalds/linux/blob/980a813/net/ipv4/tcp.c#L602

These events are reported when the “write closed” and “writable” readiness of our generic Readiness struct are set. Because the TCP socket is only added to the blocking I/O manager after it is connected or listening, we manually set this initial readiness.