---
title: "Server before client; TCP reliability"
subject: "Computer Networks and Security"
chapter: 5
key: "semester_7/computer_networks_and_security:tcp-server-before-client-reliability"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/tcp-server-before-client-reliability
site: BCT Engineering
---

# Server before client; TCP reliability

Computer Networks and Security · Chapter 5: Transport Layer

- Asked in: 2073 Chaitra, 3+5 marks; 2072 Chaitra, 3+5 marks (asked 2 times)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/tcp-server-before-client-reliability
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-5

## Question

For a client-server application over TCP, why must the server program be executed before the client program? TCP is known as a reliable process, describe how reliability is provided by TCP.

## Short answer

The server must run first to perform passive open (listen/accept); otherwise the client's SYN receives an RST. TCP provides reliability via a three-way handshake, sequence numbering, cumulative ACKs, retransmission on timeout/duplicate ACKs, checksums, and flow/congestion control.

## Answer

#### Why the server must run before the client
TCP is connection-oriented: a connection must be set up before data is sent. The server performs a **passive open**: it creates a socket, binds it to a well-known port, calls `listen()` and waits in `accept()`. The client performs an **active open** by sending a SYN to the server's IP and port.

- If the server is not running, no process is listening on that port. The server's TCP replies with **RST**, and the client gets "connection refused".
- The client needs the server's address and port, which the server program makes available by binding.
- The server must be ready to accept requests from any number of clients that may arrive at any time.

```text
Server: socket -> bind -> listen -> accept (waits)
Client: socket -> connect ------------>  SYN
                         <------------  SYN+ACK
                         ------------>  ACK   (connected)
```

#### How TCP provides reliability
1. **Connection establishment:** the three-way handshake (SYN, SYN+ACK, ACK) makes sure both sides are ready and agree on initial sequence numbers.
2. **Sequence numbers:** every byte is numbered, so the receiver can reorder segments and discard duplicates.
3. **Acknowledgements:** the receiver sends a cumulative ACK with the next expected byte number.
4. **Retransmission:** if the ACK does not arrive before the retransmission timeout (RTO), the segment is sent again; three duplicate ACKs trigger fast retransmit.
5. **Checksum:** the receiver discards corrupted segments; since no ACK comes back, the sender retransmits them.
6. **Flow control:** the window size in the ACK stops the sender from overflowing the receiver's buffer.
7. **Congestion control:** slow start, congestion avoidance and fast recovery reduce the sending rate when the network is congested.
8. **Connection termination:** FIN/ACK exchange ensures all data is delivered before closing.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why must the server start before the client?
   A. The server sends SYN first
   B. The client needs the server's MAC
   C. TCP requires alphabetical start
   D. The server must be listening (passive open) to accept the client's SYN
   Answer: D. Without a listening server, the client's SYN gets RST and connection is refused. (Key point: Passive open)

2. What happens if the client connects and no server is listening?
   A. The server's TCP replies with RST: connection refused
   B. The client waits forever
   C. UDP is used instead
   D. The router starts the server
   Answer: A. No process listens on the port, so RST is returned. (Key point: Server absent)

3. How do sequence numbers and ACKs give reliability?
   A. They choose the route
   B. They set the bandwidth
   C. They reorder segments, discard duplicates and confirm receipt
   D. They encrypt data
   Answer: C. Numbered bytes allow reordering/duplicate removal and cumulative ACKs confirm delivery. (Key point: Sequence numbers and ACK)

4. When does TCP retransmit a segment?
   A. When the window is large
   B. Only on RST
   C. When ACK does not arrive before the RTO, or after three duplicate ACKs
   D. Every second always
   Answer: C. Timeout or three duplicate ACKs (fast retransmit) trigger resending. (Key point: Retransmission)

## Related in Computer Networks and Security

- [Client-server vs peer-to-peer](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aclient-server-vs-p2p) — Computer Networks and Security, chapter 1
- [Features of client/server architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aclient-server-features) — Computer Networks and Security, chapter 1
- [HTTP request served by server](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Ahttp-request-served) — Computer Networks and Security, chapter 6

## Related in other subjects

- [Reliable client-server communication](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Areliable-client-server) — Distributed System, chapter 9
- [Architecture before specification; client-server](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Aarchitecture-before-specification) — Software Engineering, chapter 3
- [Client-side versus server-side scripting](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Aclient-vs-server-side-scripting) — Web Technology, chapter 3, asked 3×
- [Short note: Client-Server and Master-Slave](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Ashort-note-client-server-master-slave) — Big Data Technologies, chapter 1
