Reputation: 301
I used ctrl+c to terminate the socket program instead of close() function . TCP connection can be closed after a while . How dose the kernel deal with this situation? I thought only close() function could close the tcp connection.
Upvotes: 1
Views: 77
Reputation: 171246
I thought only close() function could close the tcp connection.
Why would that be? TCP is a software-defined protocol. The OS can implement it however it likes. All sensible OS'es clean up all resources that a terminated process was using. Sockets will be closed as well. What good would a TCP connection be if no process was using it and no process ever could (because the last handle was destroyed)? Makes no sense to keep the connection around if no one could ever read or write it.
Upvotes: 0