Reputation: 6008
When a process writes to a socket the kernel stores this data in an internal buffer first before pushing it though. Now if the process terminates (before closing the socket) with data still in the buffer, the kernel doesn't bother to flush them out.
So my question is:
When a process closes a socket and then dies immediately, are we in a situation where we might loose the data in the buffer? Does the kernel flush the buffer immediately when close socket is called?
Upvotes: 3
Views: 245
Reputation: 106068
From the manpage for close
:
If
fildes
refers to a socket,close()
shall cause the socket to be destroyed. If the socket is in connection-mode, and theSO_LINGER
option is set for the socket with non-zero linger time, and the socket has untransmitted data, thenclose()
shall block for up to the current linger interval until all data is transmitted.
Upvotes: 1