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 askWorth 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
MediumPut the whole chapter together: listen, check, connect.
- Create a file
index.htmlcontaining exactlyports are doors - Serve the folder on port 9108 in the background
- Fetch
http://localhost:9108/index.htmlwithcurl -s
Expected output:
ports are doorsUse the name
localhostrather than the address, to prove it resolves.
Try it 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