NETWORKING / A CONCEPT NOTE
Ports & Sockets
how one machine runs many services
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
A socket is the combination of an IP address and a port (e.g., 127.0.0.1:8080). Ports allow a single machine to multiplex traffic, routing packets to the correct application.
02 / FOLLOW THE MECHANISM
How socket connections flow
App
binds to a port (e.g., 80) and enters a LISTEN state.
Client
connects from a random high-numbered port (e.g., 51234) to server's port 80.
OS
creates a unique socket pair linking client IP:port to server IP:port.
Communication
packets flow between these specific sockets without mixing with other services.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
find what process is listening on port 8080
lsof -i :8080list all active TCP and UDP listeners on the machine
ss -tulpn05 / CHECK YOURSELF
Could you explain Ports & Sockets to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in NetworkingNAThow private IPs reach the internet