Kolam Ayer MakersLinux Foundations

Sockets

Core Idea

A socket is an endpoint a process uses to communicate, often over the network with an address, port, and protocol.

Why Sockets Matter In This Course

Client And Listening Sockets

client socket -> network -> listening socket

A listening socket waits for incoming connections. A client socket initiates a connection. For your personal service, Python listens on 127.0.0.1:<your-port>; Caddy connects to that local endpoint when handling the public service URL.

Address And Port

127.0.0.1:14567
|         |
address   port

127.0.0.1 means localhost from the machine’s point of view. The port selects the service endpoint on that address.

Commands To Try

Run ss to inspect listening and connected sockets:

ss -ltnp
ss -tnp

Use curl to test an HTTP listening socket:

PORT="$((10000 + $(id -u)))"
curl -I "http://127.0.0.1:$PORT/"

Common Failures

Proof Check

Start your user service, compute your port with printf '%s\n' "$((10000 + $(id -u)))", then run a local curl -I against that port. Explain which process is listening and which command is the client.

Docs Pointers