What is a Port: When you make network requests, you provide an IP address or a host name, along with a port.
For example:
- http://localhost:8080 (using port 8080)
- ftp://127.0.0.1:4321 (using port 4321)
So, what is a port?
A port is a method designed to enable multiple applications to respond on the same computer, using the same protocol. It’s like having different doors on a computer, allowing various services or applications to operate independently while sharing the same network connection.
For Example, let’s consider having a web server running on our machine. We could start a second web server on a different port.
Suppose the first one runs on port 80, which is the default for web servers using the HTTP protocol. The second one can run on any other port except port 80. It’s typical to use ports like 8080 or 81, for example. This way, each web server has its designated port to manage incoming and outgoing data independently.
HTTPS typically operates on port 443 as its default.
While each protocol has its designated default port, programs are not obligated to stick to it. They can choose any available port within the range of 1 to 65535 (since it’s a 16-bit unsigned number, which equals 2^16). Here’s a list of default port numbers for various protocols based on TCP and UDP.