How does TCP connection terminate if one of the machine dies?

后端 未结 5 1417
孤街浪徒
孤街浪徒 2021-02-14 04:46

If a TCP connection is established between two hosts (A & B), and lets say host A has sent 5 octets to host B, and then the host B crashes (due to unknown reason). The host

5条回答
  •  被撕碎了的回忆
    2021-02-14 05:08

    In this case, TCP eventually times out waiting for the ack's and return an error to the application. The application have to read/recv from the TCP socket to learn about that error, a subsequent write/send call will fail as well. Up till the point that TCP determined that the connection is gone, write/send calls will not fail, they'll succeed as seen from the application or block if the socket buffer is full.

    In the case your host B vanishes after it has sent its ACKs, host A will not learn about that until it sends something to B, which will eventually also time out, or result in an ICMP error. (Typically the first write/send call will not fail as TCP will not fail the connection immediately, and keep in mind that write/send calls does not wait for ACKs until they complete).

    Note also that retransmission does not reduce the window size.

提交回复
热议问题