Sockets in Action
Lesson 19 of 32 in Coddy's The OSI Model course.
An IP address plus a port, bound together inside a program, is a socket. A server listens on a socket; a client connects to it. That is layer 4 made concrete.
You can watch it happen with two tools you already have: python3 -m http.server PORT starts a listening server, and nc -z host port knocks on a port and reports (via its exit status) whether anything answered.
Servers take a moment to come up, so real scripts retry the knock a few times before concluding anything.
Challenge
MediumOpen a socket and prove it is listening:
- Start a server on port 9210 in the background
- Wait for it to come up
- Knock with
nc -zand printopenif it answers, orclosedif not
Expected output:
openTry it yourself
All lessons in The OSI Model
Practice on your own: Terminal playground