The_Diamond_Z
May 24th, 2004, 04:16 AM
I've written a socket server using IO Completion ports and I'm impressed with the results. So much so that I'm shootting for perfection in this code and I've got one last problem to deal with.
If a client dies without closing the socket connection or calling WSACleanup (I haven't worked out which but I don't think it matters) the connection on the server side remains open and the result is a memory leak (the OVERLAPPED & CompletionKey).
I've set the socket option SO_KEEPALIVE which I expected would cause a socket event when the client dies but no such luck. What else can I do?
As a practical matter, this only happens when someone is running the client code in a debugger and then stops debugging before the end of the process, but such things result in bad PR.
If a client dies without closing the socket connection or calling WSACleanup (I haven't worked out which but I don't think it matters) the connection on the server side remains open and the result is a memory leak (the OVERLAPPED & CompletionKey).
I've set the socket option SO_KEEPALIVE which I expected would cause a socket event when the client dies but no such luck. What else can I do?
As a practical matter, this only happens when someone is running the client code in a debugger and then stops debugging before the end of the process, but such things result in bad PR.