Master TCP Connection Establishment and Termination – Boost Your Skills (Updated 2025)
All application processes on the server use unique port numbers. The network administrator can use default ports (e.g., 80 for HTTP, 21 for FTP) or configure custom ports manually, ensuring no conflicts. An active server application requiring an open port on the server means the transport layer accepts and processes segments addressed to that port number. Every client’s incoming request is accepted at the correct socket address, and the application passes the data to the server. So, there are possibilities for open ports simultaneously on the same server, one for each active server application.
TCP Connection Establishment
When two people get together, they often welcome each other by shaking hands. Establishing a connection in networking is similar to the handshaking and welcoming of friends. The host and server, as well as two hosts, set up a TCP connection. The client requests a client-to-server communication session with the server.
When the server receives an ask, it acknowledges the client-to-server communication session and requests a server-to-client communication session. Then, the initiating client acknowledges the server-to-client communication session.

TCP Session Termination
After the connection is established and the job is completed, the network terminates the connection. The FIN control flag must be set in the segment header for connection termination. To end each one-way TCP session, a two-way handshake, with a FIN segment and an Acknowledgment (ACK) segment, is used. So, to end a single TCP conversation, four exchanges are required to end both sessions. The figure below illustrates the session termination process.

1 – When a host sends all data and no more data remains to be sent in the stream, it sends a segment with the FIN flag set to the server.
2 – The Server sends an ACK to acknowledge the receipt of the FIN to finish the session from the host to the server.
3 – The server sends a FIN to the host to finish the server-to-host session.
4 – The host responds with an ACK to acknowledge the FIN from the server.
When segment acknowledgment is received, the session is terminated.
TCP Connection Lifecycle Simulator
TCP 3-Way Handshake (Connection Establishment):
- SYN: Client sends SYN packet to initiate connection
- SYN-ACK: Server responds with SYN-ACK packet
- ACK: Client sends ACK packet to complete handshake
After this process, the TCP connection is established and data transfer can begin.
FAQs
-
The TCP three-way handshake establishes a connection with three steps: the Host sends a SYN, the Server responds with a SYN ACK, and the Host sends an ACK. This ensures a reliable connection before data transfer begins.