tags:

views:

278

answers:

1

Connect function returns after sending the last ACK(3rd segment of 3-way handshake of initiating TCP connection). What happens if this 3rd segment is lost because listen is still waiting for ACK at server but there is no one at client to send that ACK again ?

+1  A: 

If the client sends its ACK with a data packet, and it gets lost, the client will notice that the data hasn't been ACKd by the server and resend the packet.

If the client sends its ACK in a separate packet, and it gets lost, the server will notice that the SYN/ACK hasn't been ACKd by the client and resend the packet. Client will respond by resending the ACK.

Whether the application's connect call is still blocking at that time doesn't matter, since the ACKing is done by the OS's TCP/IP implementation.

wallenborn
You said that ACKing is done by OS implementation but ultimately connect and listen function complete the 3 way handshake. So what is the other thing that will complete the handshake?
avd
aditya: The OS kernel will do it asynchronously, when it notices that a kernel timer of some sort has expired.
caf
wallenborn: That's true unless the server is using syncookies, in which case it won't notice that the syn/ack hasn't been acked (since it keeps no record of the syn/ack it's sent).
caf