A port is a numbered endpoint on a device that directs incoming network data to the correct application — port 80 routes web traffic to a browser, port 25 routes email. A socket combines an IP address with a port number to uniquely identify one end of a network connection. Together, two sockets define a complete communication channel.
Why are port numbers needed?
An IP address identifies a device — your laptop, your phone, a web server. But a modern device runs many applications simultaneously: a web browser, an email client, a streaming service, a game. When a data packet arrives at the device, the operating system must know which application it is for.
Port numbers solve this. Think of an IP address as a street address and a port number as a flat number within a block of flats: the address gets the postman to the right building; the flat number ensures the letter reaches the right resident. Similarly, the IP address routes the packet to the right device, and the port number routes it to the right application.
Port numbers are 16-bit values, meaning they range from 0 to 65,535.
What are well-known port numbers?
Port numbers 0–1023 are called well-known ports and are assigned to specific, widely used services by the Internet Assigned Numbers Authority (IANA). Using standardised port numbers means that clients can always find a service on a predictable port without negotiation.
| Port | Protocol | Service |
|---|---|---|
| 20, 21 | TCP | FTP (File Transfer Protocol) — data and control |
| 22 | TCP | SSH (Secure Shell — remote login) |
| 25 | TCP | SMTP (Simple Mail Transfer Protocol — sending email) |
| 53 | UDP/TCP | DNS (Domain Name System — name resolution) |
| 80 | TCP | HTTP (unencrypted web traffic) |
| 110 | TCP | POP3 (receiving email) |
| 143 | TCP | IMAP (receiving email with server-side storage) |
| 443 | TCP | HTTPS (encrypted web traffic) |
You should be able to recall at least ports 80 (HTTP), 443 (HTTPS), 25 (SMTP), 53 (DNS), and 22 (SSH) for GCSE exams.
What is the difference between well-known, registered, and dynamic ports?
| Range | Name | Use |
|---|---|---|
| 0–1023 | Well-known ports | Standard services (HTTP, HTTPS, SMTP, DNS…) |
| 1024–49151 | Registered ports | Applications registered with IANA (e.g., MySQL on 3306) |
| 49152–65535 | Dynamic/ephemeral ports | Temporarily assigned to the client side of a connection |
When your browser connects to a website, the server listens on port 443 (HTTPS — a well-known port). Your browser uses a randomly chosen ephemeral port from the dynamic range (e.g., 54,219) as its source port. This source port allows the server to send responses back to your browser specifically, even if many browser tabs are open simultaneously.
What is a socket?
A socket is the combination of an IP address and a port number: IP_address:port. It identifies one end of a network connection.
A complete network connection requires two sockets — one at each end — forming a socket pair:
Client socket: 192.168.1.5:54219 (your laptop, ephemeral port)
Server socket: 93.184.216.34:443 (the web server, HTTPS port)
This four-tuple (client IP, client port, server IP, server port) is unique for every active connection. A server can maintain thousands of simultaneous connections from different clients because each has a different client IP or client port, making the four-tuple distinct for every one.
Why is uniqueness important? Without it, the operating system could not distinguish which incoming packet belongs to which browser tab or application. The four-tuple acts as a unique session identifier for each conversation.
How do TCP and UDP use ports differently?
Both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) use port numbers in their headers. The fundamental difference lies in how they handle the connection:
| Feature | TCP | UDP |
|---|---|---|
| Connection setup | Three-way handshake (SYN, SYN-ACK, ACK) before any data | No handshake — sends data immediately |
| Port usage | Server listens on a well-known port; client uses an ephemeral port | Same port concept applies |
| Reliability | Guarantees delivery and order | No guarantee — packets may be lost or arrive out of order |
| Use case | Web browsing, email, file transfer | DNS queries, video streaming, online games |
When a TCP client initiates a connection to a server, it sends a SYN packet to the server's well-known port. The server responds with SYN-ACK and assigns a socket for that specific connection, freeing the listening port to accept further new connections. This is why a web server can handle thousands of simultaneous HTTPS connections on port 443 — it accepts on 443, then manages each established connection via a separate socket.
How do ports relate to firewalls?
A firewall can block or allow traffic based on port numbers. A rule such as "block all incoming traffic on port 23 (Telnet)" prevents unencrypted remote login attempts. A rule such as "allow outgoing traffic on ports 80 and 443" permits web browsing while blocking other applications.
This port-based filtering is called stateless packet filtering when each packet is checked independently. More sophisticated stateful firewalls track the socket pair for established connections and allow return traffic automatically without needing an explicit inbound rule.
Frequently asked questions
Do I need to memorise specific port numbers for GCSE?
Yes — the main exam boards expect you to recall a small set of well-known port numbers. The most commonly tested are: HTTP (80), HTTPS (443), SMTP (25), FTP (20/21), SSH (22), and DNS (53). The full table of 65,535 ports is not expected, but knowing these specific numbers and the services they are associated with is required for marks on network questions.
Why does FTP use two ports (20 and 21)?
FTP separates its communication into a control connection (port 21) and a data connection (port 20). Port 21 carries commands — logging in, changing directory, listing files. Port 20 carries the actual file data. This separation means control commands can be sent while a large file transfer is in progress. Modern SFTP (SSH File Transfer Protocol, port 22) and FTPS merge these concerns differently, but traditional FTP's two-port design remains in the GCSE specification as a notable example.
What happens if two applications try to use the same port?
The operating system enforces exclusivity: only one process can listen on a given port at a time. If a second application tries to bind to a port already in use, the operating system returns an error ("address already in use"). This is why you sometimes see errors when starting a web server if another server is already running on port 80 — they cannot share the port.
What is a port scan and why is it used in security?
A port scan is a technique where a program sends connection requests to every port on a target device and records which ports respond. Security professionals use port scans to audit which services a server exposes — ensuring only intended ports are open. Attackers use them to discover vulnerable or misconfigured services. Running a port scan against a system you do not own is illegal in the UK under the Computer Misuse Act 1990.
Explore networking protocols and how the internet works with Professor Turing's GCSE tutoring at aitutors.me.