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?
From the manpage for close:
If
fildesrefers to a socket,close()shall cause the socket to be destroyed. If the socket is in connection-mode, and theSO_LINGERoption 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With