Closing the nest before completion

When a process writes to a socket, the kernel first stores that data in an internal buffer before pushing it. Now, if a process completes (before closing the socket) the data still in the buffer, the kernel doesn't bother to flush it out.

So my question is:

When a process closes a socket and then dies immediately, are we in a situation where we might lose data in the buffer? Is the kernel flush the buffer immediately when calling a closed socket?


source to share

1 answer

From the manpage forclose


If it fildes

refers to a socket, it close()

will destroy the socket. If the socket is in connect mode, and the parameter is SO_LINGER

set for a socket with a non-zero latency time, and the socket has uncaught data, then it close()

should block until the current latency interval until all data is transmitted.



All Articles