It is a 16-bit number used to identify specific applications and services. TCP and UDP specify the source and destination port numbers in their packet headers, This information, along with the source and destination IP addresses and the transport protocol (TCP or UDP), enables applications running on hosts on a TCP/IP network to communicate.
Applications that provide a service (such as FTP and HTTP servers) open a port on the local computer. These applications also listen for connection requests. A client can request the service by pointing the request to the application’s IP address and port. A client can use any of the locally unused ports’ number for communication. Consider the following example:
In the picture above you can see that a host with an IP address of 192.168.0.50 wants to communicate with the FTP server. Because FTP servers use, by default, the well-known port 21, the host generates the request and sends it to the FTP server’s IP address and port. The host uses any of the locally unused ports of 1200 for communication. The FTP server receives the request, generates the response,and sends it to the host’s IP address and port.
Ports’ numbers are from 0 to 65535. Certain privileged services reserve the first 1024 ports::
The combination of an IP address and one of the ports’ number is called a socket. In our example the socket would be 192.168.0.50:1200.