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
2009-09-22 15:24:06
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
2009-09-22 22:31:00
aditya: The OS kernel will do it asynchronously, when it notices that a kernel timer of some sort has expired.
caf
2009-09-23 00:21:16
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
2009-09-23 00:23:02