

This way both parties can keep track of the amount of bytes that were sent, allowing for reliable transfer on top of the unreliable IP-protocol. In TCP each byte has a sequence number that is increased for every byte sent. One important feature of this handshake is the synchronization of the TCP sequence numbers. Only after the connection has been established, data transfer takes place. No data is sent during the 3-way handshake.

Note that I use the terms client and server to clearly distinguish the party that initiates the handshake (client) from the one responding to that (server). Now the session begins and the socket is created.

Transmission Control protocol (TCP) is a connection oriented protocol. This article describes the TCP 3-way handshake and builds upon this knowledge to explain technically how port scanning works.
