3 ms·
When the socket is closed as part of exit(2), it always lingers in the background In other words, not closing the socket before exiting might actually be the e
by userbinator 5y ago
When the socket is closed as part of exit(2), it always lingers in the background
In other words, not closing the socket before exiting might actually be the easiest way to not have the connection aborted with pending data?
Note that Windows has slightly different, and perhaps the more expected, semantics for closing a socket with pending data:
https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-closesocket https://docs.microsoft.com/en-us/windows/win32/api/winsock/n...
However, any data queued for transmission will be sent, if possible, before the underlying socket is closed. This is also called a graceful disconnect or close. In this case, the Windows Sockets provider cannot release the socket and other resources for an arbitrary period, thus affecting applications that expect to use all available sockets. This is the default behavior for a socket.
- muststopmyths 5y agoActually, your quoted text applies to when SO_LINGER option is used and the semantics are exactly the same for both platforms for this option. Matching the semantics of Unix for most things was a goal of Winsock. In those days the NT TCP stack was new (compared to Berkeley TCP) and so there was a lot of effort spent to get it to match behavior so that applications did not get unexpected glitches.