The process TCP uses to establish a reliable connection.
TCP is a connection-oriented protocol, which means that before any data can be exchanged, a connection must be reliably established between the client and the server. This is achieved through a process called the three-way handshake. The process involves the exchange of three specific packets, identified by flags in the TCP header. Step 1: The client initiates the connection by sending a TCP segment with the SYN (Synchronize) flag set. This packet also contains an Initial Sequence Number (ISN), which is a random number that will be used to track the bytes in the data stream. The client is now in a SYN-SENT state. Step 2: The server, upon receiving the SYN packet, allocates resources for the connection. It then sends back a TCP segment with both the SYN and ACK (Acknowledgment) flags set. The ACK flag acknowledges the client's SYN packet (the acknowledgment number is set to the client's ISN + 1). The server also sends its own ISN. The server is now in a SYN-RECEIVED state. Step 3: The client receives the server's SYN-ACK packet. It acknowledges the server's SYN by sending a final ACK packet back to the server. The acknowledgment number is set to the server's ISN + 1. At this point, the connection is established on both sides, and data transfer can begin. This process ensures that both the client and server have agreed to communicate, have acknowledged each other, and are ready to receive data, preventing issues that could arise from delayed or duplicate connection requests.