Clients, servers, and peers
On this page
Your laptop asks another computer for a page. Later, your phone asks that same laptop for a file from a shared folder. Which computer is the server? Look at who asks and who answers in each exchange.
Name the program that asks first
Section titled “Name the program that asks first”Return to the page request. A program on laptop sends the first request. A program on web waits for that request and answers it.
A client is a program that starts an exchange by asking for something. A server is a program that waits for requests and answers them. These names describe the programs’ jobs.
For the page request, the program on laptop is the client. The answering program on web is the server. You choose the page, but the client program sends the request for you.
When web sends the page back, it becomes the sender of that message. It is still the server for this exchange. The response goes in the opposite direction from the request. The program answering does not change jobs when it sends the answer.
Look at an arrow in a drawing before naming a client. If it shows the first request, it points away from the client. If it shows the response, it points away from the server.
Separate the job from the computer
Section titled “Separate the job from the computer”A server program runs on a computer. That computer does not need a large case or a room of equipment. The program’s job is to wait for requests and answer them.
A service is something a program makes available for other programs to use. Supplying a page is one service. Sharing files from a folder is another. A server program provides the service. A client program asks to use it.
People also call a computer “a server” when it mainly runs server programs. When you read that name, think of the program doing the work. This helps you explain why an ordinary laptop can also be a server.
Give the same laptop two jobs
Section titled “Give the same laptop two jobs”First, laptop asks web for the page. Then phone asks laptop for a file. The same laptop asks in one exchange and answers in the other. The two exchanges can also happen at the same time.
For the page, the client runs on laptop and the server runs on web. For the file, the client runs on phone and the server runs on laptop. Each arrow below shows the first request.
Both pictures of laptop mean the same machine. The drawing shows the asking and answering programs. It leaves out the devices connecting the machines.
The server symbol has an inset line. The other machine symbol has a short base. They are the same size because answering a request does not require a bigger computer. Throughout the course story, web uses the server symbol because it supplies the page.
Predict: Is your phone ever a server? Think about sharing a file and letting another device join its hotspot.
Check your answer
Yes. With file sharing, a program on the phone waits for a request and answers it. With a hotspot, other devices ask the phone to join and the phone answers. A program on it also acts as a server. Devices, Links, and Connections explains how the phone then passes their messages on.
Recognize programs that both ask and answer
Section titled “Recognize programs that both ask and answer”A peer is a program that can both ask for something and provide it to another such program.
Suppose laptop and phone each share files with the other. Either program can ask for a file. Either can answer by sending a file. These two sharing programs are peers.
For each file request, you can still point to the program asking and the program answering. When phone asks for a file, its program is the client for that request. When laptop asks for a file, the jobs reverse.
Mistakes to recognize
Section titled “Mistakes to recognize”“A server is a large machine in a data center.” The file-sharing program on laptop answers phone. That makes it a server program on an ordinary computer.
“A client is a person.” You choose the page, but the program sends the request. Client names the program’s job.
Try it yourself
Section titled “Try it yourself”Goal: Find the client and server in six everyday exchanges.
- For each case, name the machine running the program that asks first.
- Name the machine running the program that answers.
- Pick one pair and describe how the programs could become peers.
Use these six cases:
- A page supplied by
webappears in the browser onphone. - A photo from
phone’s shared album appears onlaptop. laptopoffers a save-to-folder service. A file fromphoneis stored there.- The backup program on
webcollects a file fromlaptop’s shared folder. - The clock program on
laptopreceives the time fromweb’s time service. websends the page’s contents tophone. Only the response is shown.
In the time example, web also offers a time service. You do not need to turn on any sharing on your devices.
Expected: Six client/server pairs and one example where both programs ask and answer.
Hint
For all six cases, find which service supplies the result and which program uses it. When only a response is shown, work backward to the program that sent the original request.
Solution
| Case | Client program runs on | Server program runs on | Reason |
|---|---|---|---|
| Page | phone |
web |
The browser uses the page service on web. |
| Shared photo | laptop |
phone |
The program on laptop gets a photo shared by phone. |
| Save a file | phone |
laptop |
The program on phone starts the exchange to store its file using the service on laptop. |
| Shared file | web |
laptop |
The backup program on web starts the exchange to collect the file supplied by laptop. |
| Time | laptop |
web |
The clock program uses the time service on web. |
| Page response | phone |
web |
The browser on phone sent the original page request; web answers it. |
For example, the photo-sharing programs on laptop and phone could both offer photos to each other. Each could then ask for a photo and answer the other’s requests. They would be peers.
Leave for later
Section titled “Leave for later”Processes, sockets, and ports in TCP, UDP, and Ports explains how a server waits on a numbered port. The combined home router separates wireless access from the other jobs a combined device can provide.
- A client starts an exchange; a server waits and answers.
- A service is something a program offers to other programs.
- One machine can run client and server programs at the same time.
- Peers can both ask and provide.
Next, LANs, WANs, and the Internet shows how the machines’ networks connect.
Further reading
Section titled “Further reading”- RFC 9110: HTTP Semantics, §3.3, for client and server as program roles in the page exchange.