Good timeout for proto beating using TCP-Java sockets

Im implementing my own proto in Java, it will use a heartbeat over the TCP connection, which I also use to send messages and files. For the client, I use I / O lock. So, this is how I plan it to work ... I will set the socket timeout to K seconds and make a hearty reception sending messages in the interval T, so T <K. If the timeout expires, it looks like the server disabled for client or vice versa.

The heart is the server sending the line and the client, responding to another.

I do not want to spend a lot of traffic, but with a large timeout, the server may be mistaken in the status of the client.

What is a good K interval? I think about 40 seconds

PS: strings have 8 letters sent to ISO-8859-1, so its little data

+1
source share
2 answers

“K” is highly dependent on the specific application traffic profile (for example, how often the application data is transmitted) and the tolerance of the application to lose the connection (for example, how quickly the receiver should detect the loss of connection). Unfortunately, low overhead and quick detection are the opposite.

, TCP- ( RFC 793). , "", "" TCP , :

http://www.codeproject.com/Articles/37490/Detection-of-Half-Open-Dropped-TCP-IP-Socket-Conne.aspx

+3

, "" , . , , . . IM , , , .

+1

Source: https://habr.com/ru/post/1778615/


All Articles