Back to course

Port Numbers and Sockets (Service Identification)

Networking Fundamentals: The 0 to Hero Guide

Lesson 44: Port Numbers and Sockets (Service Identification)

We established that the Transport Layer (L4) uses Port Numbers to direct traffic to the correct application on a multi-tasking host. This concept is crucial for understanding how services work.

What is a Port Number?

A Port Number is a 16-bit number (0 to 65535) used to identify a specific application or service running on a computer. If the IP address is the physical building, the port number is the apartment number within that building.

The Three Port Ranges:

  1. Well-Known Ports (0 to 1023): Reserved for the most common, standard network services.
  2. Registered Ports (1024 to 49151): Assigned by IANA for specific services, often used by third-party software.
  3. Dynamic/Private Ports (49152 to 65535): Used by client machines when they initiate a connection to a server (ephemeral ports).

Key Well-Known Ports (TCP/UDP)

PortProtocolUsage
20, 21TCPFile Transfer Protocol (FTP)
22TCPSecure Shell (SSH)
23TCPTelnet (Unsecure remote access)
25TCPSimple Mail Transfer Protocol (SMTP)
53TCP/UDPDomain Name System (DNS)
80TCPHypertext Transfer Protocol (HTTP)
443TCPHTTPS (Secure Web)

The Socket

A socket is the combination of the IP address and the port number (e.g., 192.168.1.5:80). A socket uniquely identifies a single connection endpoint.