1. Library
  2. Ports
  3. Basics

Updated 2 hours ago

Imagine sending a package to a friend in a large apartment building. You know the street address, but that's not enough. The postal service needs the apartment number, or your package just sits in the lobby with nowhere to go.

This is what ports solve on networks. Your IP address is the building's street address. The port number is the apartment number. Together, they ensure data reaches not just your computer, but the specific application waiting for it.

What a Port Actually Is

A port is a number—nothing physical, just a 16-bit value between 0 and 65,535. When data arrives at your computer, the operating system checks the destination port and routes the packet to whatever application is listening on that port.

If an IP address is "123 Main Street," then a complete network address looks like "123 Main Street, Apartment 80"—or in technical notation: 192.168.1.1:80. The colon separates address from port.

Without ports, your computer could only run one network service at a time. You'd have to choose: web browser OR email client OR video chat. Never more than one. Ports create separate channels, letting dozens of applications communicate simultaneously without their data getting tangled.

The Three Port Ranges

Well-Known Ports (0–1023) are reserved for standard services. Web servers listen on port 80 (HTTP) or 443 (HTTPS). Email uses port 25 for sending. SSH uses port 22. When you type a URL, your browser automatically connects to port 443—you don't specify it because everyone agreed on this convention decades ago.

Registered Ports (1024–49151) are for specific applications. MySQL uses 3306. Microsoft SQL Server uses 1433. Game servers cluster here. These aren't as strictly controlled, but applications register their preferred ports to avoid collisions.

Dynamic Ports (49152–65535) are for temporary outbound connections. When your browser connects to a website, your operating system grabs a random port from this range as the source. When the connection closes, that port frees up for the next application.

How Multiple Connections Stay Separate

Right now, your computer might be streaming music, loading a webpage, syncing email, and running a video call—all simultaneously. How does the operating system know which incoming packet belongs to which application?

The answer is the socket pair: the combination of your IP address, your port, the remote IP address, and the remote port. This four-part identifier is unique for every connection.

You could have ten browser tabs open to the same website. Each tab uses a different source port, creating ten distinct socket pairs. When packets arrive, the operating system matches them to the right tab instantly.

This is why ports exist. Not just to identify services, but to identify conversations. Your IP address gets the packet to your building. The port number gets it to the right conversation.

Frequently Asked Questions About Ports

Was this page helpful?

😔
🤨
😃
What Is a Port? The Apartment Number Analogy • Library • Connected