100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is a Port in Networking?

Ports in networking explained — ranges, sockets, and how one IP serves many services — with commands and interview questions answered.

easyQ24 of 224 in Computer Networks Est. time: 4 minsLast updated:
Open Code Lab

Expected Interview Answer

A port is a 16-bit number (0–65535) that identifies a specific process or service on a device, letting a single IP address handle many simultaneous network conversations by pairing each one with a distinct port number alongside the transport protocol.

While an IP address identifies a device on a network, a port identifies which application on that device a packet belongs to — a web server typically listens on port 80 (HTTP) or 443 (HTTPS), while an SSH daemon listens on port 22. Ports below 1024 are "well-known" ports reserved for standard services, 1024–49151 are registered ports, and 49152–65535 are dynamic/ephemeral ports the OS assigns temporarily to outgoing client connections. A network connection is uniquely identified by the combination of source IP, source port, destination IP, destination port, and protocol — the "socket" — which is how a server can serve thousands of simultaneous clients on the same port without confusing their traffic.

  • Lets one IP address run many independent services simultaneously
  • Well-known ports give predictable defaults for common protocols
  • Ephemeral ports let clients open many concurrent outgoing connections
  • The 5-tuple (IPs, ports, protocol) uniquely identifies each connection

AI Mentor Explanation

A port is like the specific gate number at a stadium (the IP address) that directs a fan to the exact section they need — gate 80 always leads to general seating, gate 443 leads to the secure premium enclosure, and each gate serves a distinct purpose even though the stadium address is the same. Thousands of fans can enter through the same gate number at once because the stadium tracks each fan’s seat and entry ticket separately, the same way a server tracks each client’s IP and port pairing.

Step-by-Step Explanation

  1. Step 1

    Identification

    A port is a 16-bit number identifying a process/service on a device.

  2. Step 2

    Ranges

    Well-known (0–1023), registered (1024–49151), ephemeral (49152–65535).

  3. Step 3

    Pairing with IP

    IP addresses a device; ports address the specific application on it.

  4. Step 4

    The socket

    Source IP+port, destination IP+port, and protocol together identify a unique connection.

What Interviewer Expects

  • Correct definition: port identifies a process, IP identifies a device
  • Knowledge of well-known ports (80, 443, 22, etc.)
  • Understanding of the three port ranges and their purpose
  • Grasp of the 5-tuple/socket concept for uniquely identifying connections

Common Mistakes

  • Confusing a port number with an IP address
  • Not knowing common well-known port numbers
  • Thinking a server can only handle one client per port
  • Forgetting ephemeral ports are used for outgoing client connections

Best Answer (HR Friendly)

A port is like a numbered door on a computer — the IP address gets you to the right building, but the port number tells the network exactly which application inside should receive the traffic, like port 443 for secure websites or port 22 for remote access, so many services can run on one machine at once.

Code Example

Inspecting listening ports and active connections
# List processes listening on TCP/UDP ports
ss -tulnp

# Show established connections with local and remote ports
ss -tnp state established

# Test whether a specific port is open on a host
nc -zv example.com 443

Follow-up Questions

  • What is the difference between well-known, registered, and ephemeral ports?
  • How does a server handle thousands of clients connecting on the same port?
  • What is a socket and how is it different from a port?
  • Why do some services default to specific ports like 80, 443, or 22?

MCQ Practice

1. What does a port number identify, as distinct from an IP address?

An IP address identifies the device; a port identifies which application on it a packet is for.

2. Which port range is typically assigned dynamically to outgoing client connections?

Ports 49152–65535 are the dynamic/ephemeral range used for temporary outgoing connections.

3. What uniquely identifies a single network connection (the "socket")?

This 5-tuple uniquely distinguishes each concurrent connection, even to the same server port.

Flash Cards

Port in one line?A 16-bit number identifying a specific process or service on a device.

Well-known port range?0–1023, reserved for standard services like HTTP (80) and HTTPS (443).

Ephemeral port range?49152–65535, assigned temporarily to outgoing client connections.

What is a socket?The 5-tuple of source IP, source port, destination IP, destination port, and protocol.

1 / 4

Continue Learning