The Runtime Theory
Networking

The Client-Server Model

How clients and servers communicate through requests and responses, and why the distinction matters for reliability, scaling, and security.

The Runtime Theory Team5 min read#client-server#request-response#sockets
▸ On this page

The Client-Server Model

The client-server model is the dominant pattern for networked communication. A client initiates a request for a service; a server listens for requests and responds.

The Request-Response Cycle

  1. Client connects — the client opens a connection to the server at a known address (IP + port).
  2. Client sends a request — e.g., an HTTP GET /products message.
  3. Server processes the request — it reads the request, does work (database query, computation), and prepares a response.
  4. Server sends the response — e.g., HTTP 200 with the product data in JSON.
  5. Client acts on the response — renders the data, or retries, or reports an error.

Why Not Peer-to-Peer for Everything?

Peer-to-peer (P2P) — where every node is both client and server — works well for file sharing (BitTorrent). But it is harder to secure, audit, and scale for services that manage user accounts, payments, or real-time state. Servers centralize these concerns.

Stateful vs. Stateless Servers

  • Stateful — the server remembers something about the client between requests (e.g., a shopping cart stored in server memory).
  • Stateless — each request is independent; the client sends all necessary context (e.g., a session token). HTTP is stateless by default.

Stateless servers are easier to scale (requests can be load-balanced to any instance) but shift the burden of state management to the client or a shared store.

Connection Management

A socket is an endpoint for communication — a (source IP, source port, destination IP, destination port) tuple. Each connection gets its own socket on both sides.

Learn how ports and sockets work in detail.


This article is part of the Networking From the Ground Up learning path.

Not started

Sign in to save your learning progress.

Sign in to save