All application processes on the server using different port numbers. The network administrator can use default ports or he can configure ports manually for these applications. We cannot use same port numbers on the same server for different applications. For example, we cannot configure the same port number both for the FTP server and a web server. (For example, port 80 for both or port 21 port for both).
An active server application required open port on the server means the transport layer accepts and processes segments addressed to that specific port number. Every client incoming request is accepted to the correct socket address, and the application passes the data to the server. So, there are possibilities to many open ports at the same time on the same server, one for each active server application.
When two persons get together, often welcome each other by shaking hands. The connection establishment 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 sends requests a client-to-server communication session with the server.
When the server receives 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. The figure below illustrates the TCP connection establishment.
After connection establishment and completing the job the network terminate the connection. For connection termination, the FIN control flag required to set in the segment header. 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 required to end both sessions. The figure below illustrates the session termination process.
1 – When a host sends all data and no more data remain to send in the stream, it sends a segment with the FIN flag set to Server.
2 – The Server sends an ACK to acknowledge the receipt of the FIN to finish session from host to 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 acknowledgement received then the session is terminated.