Understanding Port Numbers

This article will teach you about port numbers which will help you understand why you need a  port number for Tomcat or for any application that should be accessed by others.

To work with any program, the user must load it in the RAM. This program can be loaded at any address in RAM. So, to work with the program, the user must know that address which is highly impossible. Because, every time it is loaded in a different address, randomly. For instance, today it might be loaded in 1000, tomorrow it will be 500 and so on.
       So there must be a way to ensure access to that program, no matter where it is loaded. So, is the concept of port numbers. For every program (or an application) that should be accessed by other programs, we give a port number. Whenever we want to access that program, we tell to the OS that I want to access the program that is at this port number, so connect that program to me.
         The OS maintains a map of port number and the address in RAM of the corresponding program. So, no matter where the program is loaded in RAM, that address is mapped to the port number.
         Just like, no matter where you are, anyone can interact with you by your mobile number.

Port numbers range from 1 to 65,535, where 1 to 1024 are registered for OS services. Now, for your applications you can choose from 1024 to 65535.

Photo credit: yu.edu

No comments: