What A Port Is
An IP address identifies a host, but a single host runs many services and connections at once. A port number is a sixteen bit label that identifies which application endpoint a packet belongs to.
- Well known ports below one thousand twenty four cover standard services such as eighty for HTTP and four hundred forty three for HTTPS.
- Ephemeral ports are temporary high numbered ports the operating system assigns to client connections.
Sockets And The Five Tuple
A connection is uniquely identified by a five tuple:
- the protocol, such as TCP
- the source IP address
- the source port
- the destination IP address
- the destination port
Two connections can share a destination IP and port as long as some other element differs, which is why a server on one port can serve thousands of clients at once.
Why It Matters
This is how the kernel routes an arriving packet to the right socket. A web server listens on port four hundred forty three, and each connecting client supplies a different source IP or ephemeral port, keeping every session distinct.
Key idea
A port labels an application endpoint, and the five tuple of protocol with source and destination addresses and ports uniquely identifies each connection so the kernel can demultiplex traffic.