Menu
Coddy logo textTech

Clients and Servers

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

In every exchange one side starts the conversation and the other waits for it. The side that asks is the client. The side that waits and answers is the server.

These are roles, not machines. The same computer is a server when it answers a web request and a client a second later when it queries a database. Your laptop is usually a client, but the moment you start a local development server it is a server too.

A server does something specific and slightly odd: it starts up and then waits, doing nothing, sometimes for weeks. It is listening. When a request finally arrives it answers and goes back to waiting.

The client has to know where to send its request, and the server has to be listening in the right place for it to arrive. That is the whole handshake, and when something is broken it is almost always one of those two halves.

challenge icon

Challenge

Easy

Put a server into the listening state, then check it is really waiting.

  1. Start a server on port 9102 in the background
  2. Give it a second to come up
  3. Knock on the port with nc -z and print listening if something answers, or nothing if not

Expected output:

listening

command && echo a || echo b prints a when the command succeeds and b when it fails.

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