The only way the client can tell that the server has disconnected (if disconnected gracefully) is by reading all the data until the receive function returns 0 bytes. Until that point it doesn't see the FIN flag. The server doesn't set the FIN flag in a transmitted
packet until it's sent all buffered data.
In the case of an abnormal disconnection, eventually you'll either get a timeout, or you'll get an error response to sent data if the server sets the RST (Reset) flag in a response packet.
The Connected state basically just means that you've successfully performed the three-way handshake to set up a connection (client sends SYN, server sends SYN-ACK, client sends ACK). Beyond that point it doesn't really have any significance.
why Socket class does't support events? (OnClose, OnResonse...)
Maybe because it can't detect it?
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.