When closesocket() attempts to gracefully shut down a non-blocking socket, it will attempt to create a worker thread to perform the shut down. The worker thread will attempt to notify the other end of the communication channel that the socket is shutting down. If the other end of the channel is unresponsive, the worker thread will wait for the linger timeout to expire; then do an abortive shut down.
If the linger timeout in the above scenario equals 0, then the worker thread will wait an INFINITE amount of time for the other end of the channel to respond. This thread is unable to perform any useful work, and will not exit. It has been leaked. The memory associated with the thread and the socket it is trying to shut down has also been leaked.
Alternatively, you may set the linger timeout value to a value other than 0 - for example 1 second. The worker thread will only wait for the specified linger timeout value before shutting down the socket and exiting.
Please see the following MSDN help article for more background information about linger,
Graceful Shutdown, Linger Options, and Socket Closure
Id. de artículo: 2770054 - Última revisión: 18 oct. 2012 - Revisión: 1