The client-server model

Who listens and who takes the initiative, the socket, listening port and ephemeral port, the five values that identify a connection, one server for many clients, stateful or stateless, and peer-to-peer by contrast.

  • 25 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios
  5. Understand

A few cards from the deck

  • Client: what is it?

    Show the answer

    The program that takes the initiative: it opens the connection to a server whose address and port it knows, then sends its requests.

    A browser, ssh or curl are clients. The role belongs to a program in an exchange, not to a machine: one computer can be a client in one place and a server in another.

  • A web server listens on port 443 and serves 1,000 clients at once. How does it tell their connections apart?

    • By each connection's five-tuple, where the source address or port differs
    • It opens a separate listening port for each client that connects to it
    • It relies on each client's MAC address, read from the received frame
    • It waits for one connection to end before accepting another on port 443
    Show the answer

    By each connection's five-tuple, where the source address or port differs

    A single listening port is enough: each accepted connection has its own five-tuple. Two clients behind the same box share the public address but not the source port, and the box's translation table keeps them apart.

  • The program that sends the first packet of a TCP connection plays the … role, whatever machine runs it.

    Show the answer

    The program that sends the first packet of a TCP connection plays the client role, whatever machine runs it.

    The other program, the server, was already listening on a known port: it must therefore be started first. The client can change its address and port at every connection.

  • Server: what is it?

    Show the answer

    The program that waits, on a known address and port, for clients' connections and answers their requests.

    It waits for clients to come to it. One server serves many clients at once: a single listening port, one connection per client.

  • A second server is started on port 8080 while a first one already listens there. The second stops with “Address already in use”. Why?

    • The first server has reserved every port above 8000
    • A port can serve only one client at a time, which therefore occupies 8080
    • Port 8080 is reserved for the administrator, and the second server lacks root rights
    • A listening address and port pair has only one program
    Show the answer

    A listening address and port pair has only one program

    The system ties a listening socket to a program: it would not know whom to hand the incoming connections to if there were two. The fix is another port, or stopping the first. The port itself serves many clients at once.