I looked at documentation about this but shouldn't a socket linger be declared before the close so the program doesn't immediately abort before it knows what kind of shutdown to expect? Shouldn't linger be used first to explain to the socket close the shutdown should be one way or another? I'm looking at previously used code and the microsoft documentation but it just seemed odd to me.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms738547(v=vs.85).aspx
From this code, couldn't the socket immediately shutdown from the sockClose and the linger would be ignored? Code:
self->socket = sockAccept(srvSocket)
sockClose(srvSocket);
sockDelay(self->socket, 1);
sockBuffer(self->socket, pileSize + sizeof(messages));
sockLinger(self->socket);