Good day.
In the GroupSock library closing of a socket is not fully correct. Closing there is just uses CloseSocket (aka closesocket). When the input or output buffer is not empty, socket handle wil not be freed. It's ok, when the application just opens a few sessions and then exits, but when application is working long time and often connects and reconnects, there will be the situation when handle amount (can be changed with ulimit) will run over. To avoid that it is necessary to call shutdown(socket, SHUT_RDWR) first, to clean up both buffers and to stop receiving any data, then CloseSocket(socket) will definitely close it and file handle will be released.
Good day. In the GroupSock library closing of a socket is not fully correct. Closing there is just uses CloseSocket (aka closesocket). When the input or output buffer is not empty, socket handle wil not be freed. It's ok, when the application just opens a few sessions and then exits, but when application is working long time and often connects and reconnects, there will be the situation when handle amount (can be changed with ulimit) will run over. To avoid that it is necessary to call shutdown(socket, SHUT_RDWR) first, to clean up both buffers and to stop receiving any data, then CloseSocket(socket) will definitely close it and file handle will be released.