summaryrefslogtreecommitdiff
path: root/What is TCP KeepAlive.md
blob: 6b25179477abed889389a0cab8400be18ee97942 (plain)
1
2
3
4
5
6
7
8
9
TCP KeepAlive: Keeps TCP Alive.

A timer is set up together with the TCP connection, if the timer reaches zero a probe packet is sent without any data. It has a flag set for ACK. The peer only has to support TCP/IP, not specifically keepalive. If alive it will respond with a zero data packet as well that has the ACK flag set.

Because TCP lets your program handle a stream, not packets, a zero length data packet is not dangerous for the program listening on the socket.

Two use cases for keepalive:
- Detecting dead peers
- Prevent disconnects due to inactivity