K
K
Konstantin2020-05-29 16:50:42
Network administration
Konstantin, 2020-05-29 16:50:42

When will the TCP connection be terminated?

Hello.
I am writing a TCP server program and a client to it. The functionality is tied to the presence or absence of a TCP connection with the second host (server-client).
Those. the task is to understand that now there is a network / tcp connection, but right now there is no (disconnect event).
The question arose: after establishing a tcp connection, how long will this connection be active or after what time will it break. Who determines this time? Where is this setting stored?
Thank you.

Now I check the connection like this: every 15 seconds I send constant text requests "ping" and if the answer "pong" comes in a given time, for example 2 seconds, then the connection is active. If you receive a disconnect event, it means that there is a break - there is no connection. But it seems to me that this is not correct.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-05-29
@webmaster

But it seems to me that it’s normal, it’s worth reading https://habr.com/ru/company/mailru/blog/316128/ and everything will immediately become clear.

V
Vladimir Korotenko, 2020-05-29
@firedragon

Read rfc it describes tcp time-out, so catch it, and pings are too much

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question