TOPIC NETWORKING
Ports & Sockets how one machine runs many services
IN 10 SECONDS
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.
GOTCHA 'Address already in use' error means another process is already bound to that port. Kill it or use another port.
HOW SOCKET CONNECTIONS FLOW
01 App binds to a port (e.g., 80) and enters a LISTEN state.
02 Client connects from a random high-numbered port (e.g., 51234) to server's port 80.
03 OS creates a unique socket pair linking client IP:port to server IP:port.
04 Communication packets flow between these specific sockets without mixing with other services.
POKE IT YOURSELF
lsof -i :8080 — find what process is listening on port 8080
ss -tulpn — list all active TCP and UDP listeners on the machine
Drill this topic →
~60 sec read