Prerequisite – Internet and Web programming, The Internet and the Web, and TCP and UDP in Transport Layer
Port can be treated as a gateway to Internet. To facilitate different applications to make connections at the same time, each device connecting to web uses ports in a different manner. All operations are carried out using different ports when we simultaneously use web, download some files, use a printer, etc. For instance, HTTP transfers use port number 80, whereas Telnet uses 23.
As it is known, device (i.e., computer) is identified by its IP address. Since multiple services (tabs) or applications run by web browser simultaneously, to run network applications, the IP address alone is not sufficient.
Network port facilitates in identifying application or service running in browser/computer in same fashion as IP address does.
Looking into an analogical situation –
Supposedly you own a building. The street address corresponds to IP address. Also, the way there is a port number, each building also has a building number.
Port numbers are also of different types and have unique numbers. The ports co-exist within an IP address because each and every service has its unique port.
Top firms like Google or MSN use well-known ports (0 to 10231) for their services; Certain specific functions are assigned registered ports(1024 to 49151) when requested; There are also private or dynamic ports(49152 to 65536) which can be used by anyone who wishes for private servers and temporary purposes.
It is highly advisable for you to know port numbers. You’ll have good control of your software if you know it. Applications should always be open for them to work since they use specific ports. While closing them can certainly improve your port security, it is upon you to keep a particular port open or close. You may also open or close a particular port if one of your apps aren’t able to get connected to Internet. Some ports are blocked by firewalls, so you may have to manually allow it to bypass them when needed.
The need for a port number is discussed for now. But, who assigns a unique port number for different services/applications ?
A web browser when connected to a web server, a port in range (49152- 65535) is self-allocated by web browser, which is called an ephemeral port.
In image shown underneath, all unique services are assigned a unique port number, which you can see on 5th tuple on local address. Try netstat on your command to get details.
Client port numbers are dynamically assigned, and can be reused once session is closed.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.