What is Port in Context of Client Server Communication

IP address is unique numerical address of each computer directly connected to internet. If you want to send data to a computer, all you need is the IP address of that computer. But data is received by some program running on a computer. If you send data to a computer just specifying its IP address, how can that computer decide which program the data should be passed to? (as a computer runs multiple programs).

Here comes the port. Port is a number used to specify which program should receive the data. So when a computer send data to another, in addition to IP address, the sender also specify the port number so that the operating system could decide the target program where data should be passed.

Say there is a computer with IP address = 172.43.98.34 which is running a web server (a program that receive HTTP request and send response) on port 88. You can access it by point your web browser to http://172.43.98.34:88/

Some pre-defined port numbers are used for particular type of services. So that its easy for users to send requests to server. For example port 80 is used for web server. Its mean, if you want to request a resource from web server, you would specify port 80. As port 80 is default web server port, that's why we don't specify when we request pages using our web browser. So if the port number is not specified, the web browser assume the server is listening or running on stand web server port i.e. 80. Hence it automatically adds port number 80 when sending request packets to server.

Comments