Skip to the workspace
Pebellslearn by building
What Are Networks?  ›  Lesson

Protocols, Ports and Sockets

Port 14 minA protocol sets the rules of a conversation, a port number picks the program on a host, and a socket is an IP address plus a port.

network engineer / Protocols, Ports and Sockets

Explore each scene at your own pace.

01 · The rule

The rule

Protocols, Ports and Sockets

The files box at 192.168.10.20 does three jobs at once: it shares folders, serves a small web dashboard and accepts remote logins for the IT person. Packets for all three arrive at the same IP address. How does the box know which program each packet is for, and how do both sides agree on what the bytes mean?

The rule

The protocol sets the rules; the port picks the program; the socket is the plug.

Protocol — an agreed set of rules for a conversation: who speaks first, what each message looks like, what counts as an error. HTTP is a protocol for web pages, DNS for name lookups, TCP for reliable delivery. Two devices can only talk if they speak the same protocol.

Port — a number from 0 to 65535 that identifies a program or service on a host. The IP address gets the packet to the right machine; the port gets it to the right program on that machine. Ranges to know:

Range Name Used for
0–1023 well-known standard services: 22 SSH, 53 DNS, 80 HTTP, 443 HTTPS
1024–49151 registered assigned to specific applications
49152–65535 dynamic (ephemeral) temporary ports that clients pick for their side of a conversation

Socket — one end of a conversation, written as an IP address plus a port, such as 192.168.10.20:443. A server program opens a socket and listens on it. A single connection is identified by both ends together with the transport protocol: source IP, source port, destination IP, destination port and protocol. Because the client's ephemeral port differs for each connection, one server socket can serve hundreds of connections at the same time.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.