Opening a TCP connection involves exchanging three packets. These packets are SYN, SYN+ACK, and ACK. They are called this way because the TCP header has SYN (for synchronize) and ACK (for acknowledge) bits. The first packet as the SYN bit set (equal to one), the second packet has both these bits set, the third packet has only the ACK bit set.

This exchange is used to establish initial sequence numbers of the connection. After the three-way handshake is complete, connection is established.

What happens during this famous handshake ?

Two hosts want to talk to each other in a reliable way. UDP is unreliable - out of the question. Besides, you want to move loads of data, not worrying about sequence, lost packets and so on. This leaves TCP. Reliable. Will do everything to make sure your data reaches the target unmolested. At a price, though. The price is the extra overhead of acknowledging every packet (just to make sure it arrived).
Plus - packets have to know the secret handshake :

"Hey you ! I wanna talk to you !" (SYN)
"Cool ! Hey you ! I wanna talk to you !" (ACK, SYN)
"Cool !" (ACK)

At the end of the day, when everything that needs to be said is said, another exchange takes place :

"That was all." (FIN)
"Cool ! That was all." (ACK,FIN)
"Cool !" (ACK)

So - in almost every TCP connection that is not just broken somehow, you have two three-way handshakes.

(Please make sure to check out TCP half-close, though !)

Log in or register to write something here or to contact authors.