A web server is listening on port 443. Simultaneously, 500 clients from different locations are each connected to it. How is this possible given that port 443 is a single 16-bit number?
AThe server opens a new, unique port number for each client after the initial handshake
BEach TCP connection is uniquely identified by the four-tuple (source IP, source port, destination IP, destination port), so many connections can share the same server port
CUDP is used instead of TCP so the server does not need to track individual connections
DThe operating system assigns a distinct IP address to each simultaneous connection
The server port (443) is the same for all connections, but each connection is uniquely identified by the full four-tuple. Client 1 from IP 10.0.0.1:52300 and Client 2 from IP 10.0.0.2:48721 both connect to 443, but the OS matches each incoming packet to the right socket using all four fields. This four-tuple uniqueness is what allows a single server port to handle thousands of simultaneous connections — a fundamental insight that distinguishes socket-level understanding from simple port-numbering knowledge.
Question 2 Multiple Choice
A developer tries to start a server on port 8080 and receives an 'address already in use' error. What is the most likely cause?
APort 8080 is a well-known port reserved for standard services and cannot be bound by user applications
BThe operating system has exhausted its ephemeral port range and can no longer accept new connections
CA socket bound to port 8080 still exists — likely a recently closed TCP connection still in the TIME_WAIT state
DThe developer's firewall is blocking port 8080 from being bound locally
When a TCP connection closes, the OS keeps the socket in TIME_WAIT state for a period (typically 2× the Maximum Segment Lifetime, ~60–120 seconds) to ensure all packets from the previous connection have been delivered before the port is reused. During this window, the port is still 'in use' even though no application is actively using it. This is the most common cause of the error during development. Solutions include waiting, using SO_REUSEADDR socket option, or restarting with a different port.
Question 3 True / False
A server process listening on port 80 can handle at most one TCP connection at a time, because a port is a single number and two connections cannot simultaneously share the same port.
TTrue
FFalse
Answer: False
This is the key misconception about ports. A single server port can handle thousands of simultaneous connections because connections are identified by the four-tuple (src IP, src port, dst IP, dst port), not by server port alone. Each client contributes a unique (client IP, client ephemeral port) pair, making every connection's four-tuple globally unique. The OS demultiplexes incoming packets using all four fields and routes each to the correct socket. The server port 80 appears in every connection's four-tuple, but that doesn't conflict — it's the remaining two fields that distinguish them.
Question 4 True / False
Ephemeral ports are temporary port numbers assigned by the operating system to the client side of a connection, ensuring that the server's reply packets are routed to the correct application process on the client.
TTrue
FFalse
Answer: True
When a client opens a connection, its OS assigns an unused ephemeral port (typically in the range 49152–65535) as the source port. The server's replies are addressed to (client IP, client ephemeral port), which the OS uses to route the data to the correct socket — and thereby the correct application or browser tab. Without ephemeral ports, if every connection from a machine used the same source port, the OS could not distinguish which application should receive a reply, and simultaneous connections from the same host would be impossible to demultiplex.
Question 5 Short Answer
A web server listens on port 443. When a client connects, the OS assigns an ephemeral port as the connection's source port. Why is this ephemeral port necessary, and what would go wrong if all client connections used the same source port?
Think about your answer, then reveal below.
Model answer: The ephemeral port is the client's contribution to the four-tuple (src IP, src port, dst IP, dst port) that uniquely identifies each TCP connection. If every connection from the same client machine used the same source port — say, 12345 — then all reply packets from the server would arrive with the same four-tuple, and the OS could not tell which socket (which browser tab, which application) should receive each packet. Two simultaneous connections to the same server would be indistinguishable. By assigning a different ephemeral port to each new connection, the OS ensures that every active connection has a unique four-tuple and can be correctly demultiplexed.
This is also why a browser can open many parallel connections to the same website: each tab or each resource request gets its own ephemeral port, making each connection uniquely identifiable even though the destination IP and port are identical. The source port is what creates uniqueness on the client side.