rgaufman / live555

A mirror of the live555 source code.
GNU Lesser General Public License v3.0
745 stars 366 forks source link

Slightly incorrect socket closing #42

Open dshurbin opened 1 year ago

dshurbin commented 1 year ago

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.