sockets - Are FIN packets guaranteed to arrive? -


in 4-way handshake, have following:

fin -------> <------- ack <---x--- fin (what if packet lost?) ack -------> 

what happens if third packet lost, re-transmitted? note time third packet sent, program have destroyed socket, , can't send anymore!

tcp protocol

all segments preceding , including fin retransmitted until acknowledged.

source: https://tools.ietf.org/html/rfc793

socket

you can use operating system tools see open tcp sockets , states. during tcp finalization socket first open bi-directional communication, each side closes direction , each fin has acknowledged before resources freed in operating system.

in order retransmit fin packet, connection must still represented in os until fin acked or timed out.


Comments