What is Port Number ??
On our laptop, many programs are running such as Chrome, Brave, VS Code, and many internal programs. The program that needs to connect outside the world, i.e. to the world of the internet, needs port numbers. And the programs that have nothing to do with the internet and running for internal use cases and other things, don't need a port number.
Now the question arises is why the programs that connect with the outside world need port numbers?? So, in order to get this answer, let's try to understand with an example.
So you open a browser say Chrome, and in one tab YouTube is open, in another tab Twitter is open, in another tab Github is open, and in the last tab LinkedIn is open. When you request for YouTube from the first tab then in the result, you will get YouTube-related results only, You can not get results of other tabs such as Twitter, github, or LinkedIn which are present adjacent to YouTube tabs. This is because each tab is differentiated with unique numbers, i.e. port number. When a request is being made from a particular tab, each tab is assigned with a port number. As your laptop gets a response from that server, the response is sent to the port number from which the request was sent out. The tab associated with that port number receives the response from the server. So, basically, your computer/laptop uses the port number to differentiate b/w the "n" number of programs running on your laptop. And since the port number is attached to the tab, that response is sent into that tab.
Note: Each new tab you open on the browser is assigned a different and unique Port Number. Port Number lies in b/w 0 to 65353. Basically, there are 3 types of Ports:
- Well Known Ports(0-1023)
- Registered Ports(1024-49151)
- Dynamic or ephemeral ports(49152-65535)
To check all ports exposed in your laptop, run the below command:
netstat -a
Comments
Post a Comment