Menu
Coddy logo textTech

Recap: Ports

Lesson 14 of 47 in Coddy's Networking with the Terminal course.

The address is the machine, the port is the program on it, and the two together are a socket.

Servers listen, clients connect, and only one program can listen on a given port at a time.

python3 -m http.server 9108 &   # listen
nc -z 127.0.0.1 9108             # is anything there?
curl -s http://127.0.0.1:9108/   # connect and ask

Worth remembering: 22 SSH, 53 DNS, 80 HTTP, 443 HTTPS, and that ports under 1024 normally need administrator rights.

And the two failures that mean different things: refused is reachable but nothing listening, timeout is nothing answered at all.

challenge icon

Challenge

Medium

Put the whole chapter together: listen, check, connect.

  1. Create a file index.html containing exactly ports are doors
  2. Serve the folder on port 9108 in the background
  3. Fetch http://localhost:9108/index.html with curl -s

Expected output:

ports are doors

Use the name localhost rather than the address, to prove it resolves.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground