socketstcpconnectionserversocket

what should the server do when a conneceted client was force killed the process which both using tcp socket?


while using net and stream socket, after client connect server, what should the server do when a conneceted client was force killed the process which both using tcp socket? does the server know when a connected client was force killed the process?


Solution

  • The server knows when a client socket gets closed, which it implicitly does when the process owning the socket gets killed. The server does not get the reason why the socket gets closed though.

    So there is no way for the server to react specifically at a socket close due to process killed. The server can only react to a socket closed at a time when the server does not expect the socket to get closed. How the server should react to this depends on the specific use case, i.e. there is no universal behavior.