Client-Server Communication
How the frontend and backend talk over the internet
Introduction
You tap a button in an app, and moments later, fresh data appears on your screen. But how did that data get there? It travelled across the internet — from a server thousands of kilometres away — in a conversation between two pieces of software: the client and the server.
The client is your device — your phone, laptop, or tablet running the frontend. The server is a remote computer running the backend. They communicate by sending messages called requests and responses over a protocol called HTTP.
In this chapter, you will learn exactly how client-server communication works, step by step, and the technologies that make it possible.
How It Works
When the client needs data, it sends an HTTP request to the server. The request includes a method (GET, POST, PUT, DELETE), a URL, headers, and optionally a body. The server processes the request and sends back an HTTP response with a status code, headers, and the requested data (often in JSON).
Postal Mail Analogy
Imagine you send a letter (request) to a company. You write the address (URL), what you want (method + body), and your return address. The company receives your letter, reads it, processes your request, and mails a reply (response) back to you. The internet is the postal service that carries the letters.
The Six Steps of Communication
Here is what happens when you interact with an app:
1. User Action
You tap a button, submit a form, or pull to refresh. The frontend detects this action.
2. HTTP Request Created
The browser or app builds an HTTP request with the method, URL, headers, and any data.
3. Travel Over Internet
The request breaks into packets and travels across routers, fibre cables, and satellites to the server.
4. Server Processes
The server receives the request, runs the backend code, checks auth, queries databases, and prepares data.
5. Response Sent Back
The server sends an HTTP response with a status code (200 OK, 404 Not Found) and data (HTML, JSON, etc.).
6. Browser Renders
The frontend receives the response and updates the UI — showing new data, a message, or an error.
Deeper Dive
The communication happens over TCP/IP — the fundamental protocol of the internet. TCP ensures that all data packets arrive in the correct order. IP routes each packet to the correct destination using IP addresses.
HTTP (HyperText Transfer Protocol) sits on top of TCP/IP. It defines the format of requests and responses. HTTPS is the secure version — it encrypts all data so that nobody can read it in transit.
Latency is the time it takes for a request to travel from client to server and back. It is measured in milliseconds. Even 100ms of latency can feel slow to a user. That is why servers are placed in data centres all over the world — to be closer to users.
Key Insight
The client and server do not need to know anything about each other's internal code. They only need to agree on the format of the messages they exchange — this is called a protocol.
Advanced
At a deeper level, client-server communication involves rules and patterns that engineers use worldwide. Client follows standards so different brands and devices can still work together. That is why your phone, school laptop, and game console can all connect to the same network or use the same apps.
Server does not happen in a straight line. Systems often use backup paths, error checking, and retries so information arrives correctly. When something fails, smart Request helps the system recover instead of shutting down completely.
Scientists and engineers keep improving these systems every year — making them faster, safer, and more energy-efficient. The ideas you learn in this chapter are the same building blocks used in real data centers, robots, apps, and websites around the world.
Vocabulary Table
| Term | Definition |
|---|---|
| Client | A device or application that requests data or services from a server |
| Server | A computer or program that provides data or services to clients over a network |
| Request | A message sent from a client to a server asking for data or an action |
| Response | The data or status sent back from a server to a client after processing a request |
| HTTP | HyperText Transfer Protocol — the standard protocol for web communication |
| TCP/IP | The core protocols of the internet that route and deliver data packets reliably |
| Latency | The time delay between sending a request and receiving a response |
Fun Facts
HTTP was created by Tim Berners-Lee in 1989. The first ever HTTP request was "GET /index.html" — and it worked.
An HTTP request can travel from New York to Sydney and back in about 250 milliseconds — faster than the blink of an eye.
Google found that a 400ms delay in search results caused a 0.44% drop in traffic — proving that even tiny latency matters.
The most common HTTP status codes are 200 (OK), 404 (Not Found), 500 (Server Error), and 301 (Redirect).
Over 70% of internet traffic is now encrypted using HTTPS, which adds a layer of TLS/SSL security on top of HTTP.
Interactive Diagram
Launch the interactive diagram to see this in action.
Open Interactive DiagramThe interactive diagram for this chapter demonstrates Client-Server Communication. It shows a client device sending requests to a server, with request/response cycle animated.
What to explore:
- click "Send Request"; watch the request travel over the network; see the server process it; watch the response come back
- client-server communication follows a request-response pattern — the client asks, the server processes and responds
Knowledge Check
1. What does HTTP stand for?
Answer: HyperText Transfer Protocol
2. What is latency?
Answer: The time delay between sending a request and receiving a response
3. Which HTTP status code means "Not Found"?
Answer: 404
