As said in the last post, we would be discussing setting up a client-server connection. But we can setup a connection in different ways. Here we are going to discuss the three-way handshake to setup a connection.
Consider the below diagram where we are having a client and a server and the client is running a browser for instance.
Imagine if the web browser wants to send in some information to the server. Before sending the data we should be establishing a reliable connection between the client and the server.
The client starts to set up a three-way connection to the server by sending the client a SYN packet. The SYN packet basically consists of a sequence number that tells the server on how to connect the client.
The server then sends back in the client a SYN + ACK where ACK denotes the Acknowledgment telling that it has received the request.
The server then client then sends a confirmation acknowledgment noting that it has received the SYN + ACK.
Hence the connection is established.
We similarly have a closing connection for the three-way handshake which is up to you to find out.
I would be implementing a three-way handshake in the TCP/IP implementation.
To check out the progress of the application click the Link