# Handshaking (computing)

Handshaking is the connection between the computer and a device. Handshaking is required in order to allow both the computer and device to send protocols to each other. During a handshake, the two devices make sure that they know certain connection requirements of each other. For instance, they will need to find out a suitable bit rate and latency for each other.

Examples of devices that use this method include a modem or another computer. Normally, handshaking happens between two devices. Although, a TCP three-way handshake is a special type of handshake that involves sending a connection from one computer to another, just done three times.

## Examples

### TCP three-way handshake

This method is used to connect two hosts on a computer network together, each host known as the client (the main host) and the server (a distant host), respectively. Once the client wants to make a connection to the server, the client can start a TCP three-way handshake with the server. This will allow the client computer (the main device) to send and receive messages to and from the server (a distant device) once the process is complete. Starting a normal TCP connection requires three separate steps:

1. The first host (Alice) sends the second host (Bob) a "synchronize" (SYN) message with its own sequence number ${\displaystyle x}$. Bob will then receives Alice's sequence number.
2. Bob replies with a synchronize-acknowledgment (SYN-ACK) message with its own sequence number ${\displaystyle y}$ and acknowledgement number ${\displaystyle x+1}$. Alice will then receive Bob's message, which contains both his sequence number and his modified acknowledgement number.
3. Alice replies with an acknowledgment (ACK) message with acknowledgement number ${\displaystyle y+1}$. Bob will receive this message, but at this stage he doesn't need to reply.

In this setup, a synchronize message will request a server to make a connection with each other, while the acknowledgement messages return to the requesting server to let it know the message was received. Letting both hosts send synchronize messages to each other will allow the two hosts to connect with each other in both directions. Each acknowledgement message sent to each other ensures they are still connected with each other.