2
votes

I have questions about the time limit for the tcp binding socket in server side.

In my survey, I found if the tcp client socket send the close message to the server, the client will enter to TIME_WAIT state last for 2 MSL.

If the client socket connect to server, but didn't send the close message. And it's also not send any data to server. Do the server side socket bind this socket continuously and not to close it forever until server down?

Is there a limited timeout for the tcp binding socket in the server side?

Thank you for your read and hopefully for your reply.

1

1 Answers

0
votes

No there's no time limit. A connected socket stays connected until the connection is closed.

If you want to make sure that both ends of a connection is still alive, you could add such a "is alive" message to your protocol, and if the the other doesn't answer within some time limit you can close the connection. There is also the builtin functionality of SO_KEEPALIVE socket option which will handle this for you, but the default timeout is two hours for that.