Sending a FIN is an indication that the end won't send any data. But can it send TCP keepalive?
If it can then it contradicts the statement of "sending stuff after FIN" even though it is keepalive but not data.
If it doesn't send keepalive, it won't detect if the other end is gone.
For ex:
Client send FIN and got ACK back. Server then sent a reset which was lost. Only way the client can detect that server has gone away is by sending keepalive which will be responded with reset and then the client closes.
Does this happen?
The SO_KEEPALIVE socket option is valid only for protocols that support the notion of keep-alive (connection-oriented protocols). For TCP, the default keep-alive timeout is 2 hours and the keep-alive interval is 1 second. The default number of keep-alive probes varies based on the version of Windows.
Client-side keepalive: Clients sends TCP keepalive to prevent the server from closing the TCP connection to the client. Both-side keepalive: Both server and clients send TCP keepalive as described in 1 and 2.
The keepalive concept is very simple: when you set up a TCP connection, you associate a set of timers. Some of these timers deal with the keepalive procedure. When the keepalive timer reaches zero, you send your peer a keepalive probe packet with no data in it and the ACK flag turned on.
A TCP Keep-Alive, originally defined in Request for Comments (RFC) 1122, is an empty TCP segment intended to cause the peer to send an ACK. The default is 1800 seconds. Note: For more information about TCP keep alive, refer to the Internet Engineering Task Force (RFC 1122).
According to RFC-1122:
Keep-alive packets MUST only be sent when no data or acknowledgement packets have been received for the connection within an interval.
Sending FIN
is only an indication that no more data will be sent, not that no more data can be received. If the application after sending FIN
is still expecting data, the RFC indicates it can send a keep-alive packet to make sure the other end is still there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With