IP Addresses, Ports and Sockets


Generally, a computer is connected to a network through a single Network Interface Card, commonly known as the Network Card. Each network card is assigned an IP addresses that will allow other computers to identify and communicate with it using this address. All data that are exchanged between an application running on a computer and the outside travels via this interface. A computer may at any given time run several applications that require communication with external processes. In order to identify the data that is associated with each application, the concept of a port is introduced. A port can be considered as a gateway to an application. Each application is associated with a particular port, and each port is given a unique number, as shown in the Figure.

An application that need to use the services of another application running on a remote computer need to identify the service required by specifying the IP address and the Port no. Some of the ports are well-known, for e.g. Web servers generally run on Port 80, and hence there is no need to specify the port number explicitly when a web client such as Firefox or Internet Explorer connects to a web server running on the Port 80. However, if the web server is running on any other port, then the client needs to specify the IP address as well as the port number.

When a process needs to connect to another process, the two processes establish a two way communication link between themselves. Each end-point of this communication link is called a socket. In essence, the two applications that need to exchange the data create a pair of sockets that act as the end-points of the communication link.


As we see in Figure, a socket is an end point of a communication link between two applications, for e.g. a client program and a server program. All communication between two processes happen through sockets, while the identification of a particular process is done with an IP address and a port number.

No comments