Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Closing TCP Connection Question?
I am confused on how do TCP work. I was testing this. I have a TCP Connection established between two clients (Client A and B), nothing is being transmit between the two clients. When I forcefully close one client (say Client B) by shutting down the process, I was expecting the other side (Client A) will not notice. Since no close connection request between two side. The testing is implemented in Java.
Supprisingly, the other immediately throw an exception:
java.net.SocketException: Connection reset
I don't understand that, how does the other know that the link is broken? I can only think of there is some underlying mechanism in the TCP stack which keeps on sending alive packet to test the link. Is that true? which layer is it? or there is some other thing that cause this to happen?