Using the poll method in the socket class, you can.
Socket client//If it has already been created, connect to the server-side of the socket to the clients object.
We just need the client. Poll (10,selectmode.selectread) judge on the line. As long as the return true is. You can assume that the client has been disconnected.
The Poll method will check the status of the Socket . Specifies the SelectMode parameter of the SelectMode.::. Selectreadto determine if the Socket is readable. Specify selectmode.::. Selectwriteto determine if the Socket is writable. Use SelectMode..::. Selecterror Detection error condition. Poll will block execution within a specified period of time (in microseconds). If you want to wait for the response indefinitely, set microseconds to a negative integer. If you want to check the status of multiple sockets, you may wish to use the Select method.
This method does not detect certain types of connection problems, such as a network cable outage or a remote host shutting down unexpectedly. You must try to send or receive data to detect these types of errors.
How the C # Socket server side determines client disconnects