When a socket is closed at one side of the communication, the other side will not get to know this information. In your case, when ctrl+c is performed, socket is terminated abruptly at host1 end. Until, host2 tries to read from this broken connection, host 2 will not know that the connection is broken and it will keep the same conn alive. The moment, host2 tries to read from this socket, it will come to know that the connection is broken and it will terminate the connection. The logical flow of function(system calls) at host2 would be
read() -> Application would receive an error on read call shutdown() ->depends on the application you are using close() Then depending on the application, if it decides to terminate, it will call exit() as well. you can see the man pages of these commands for more information. On Fri, Nov 7, 2014 at 2:37 AM, Grzegorz Dwornicki <[email protected]> wrote: > Hi > > I have a big interest in how kernel handles this situaction. > > Lets assume that we have two hosts: host 1 and host 2 and on host 1 I > have started this command: > nc -l -p 4444 > on host 2 I have started this command (2 means IP addres of second host > here!): > nc 2 4444 > > Now i can send msgs betweem them. In time I have decided to end > connection. To do this I'm using ctrl+c on host 2. What functions are > called to clean broken socket on host 1? What functions are called to > clean up socket on host 2? > > Grzegorz. > > _______________________________________________ > Kernelnewbies mailing list > [email protected] > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > -- Regards, Sreejith -------------------------------------------------------------------------------------------------------- Aint no grave, can hold my body down!!! "Obadiah 1:4"
_______________________________________________ Kernelnewbies mailing list [email protected] http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
