- Asked 2/11
- 2073 Chaitra · 3+5 marks
- 2072 Chaitra · 3+5 marks
Server before client; TCP reliability
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.
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.
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.
Server: socket -> bind -> listen -> accept (waits)
Client: socket -> connect ------------> SYN
<------------ SYN+ACK
------------> ACK (connected)
How TCP provides reliability
- Connection establishment: the three-way handshake (SYN, SYN+ACK, ACK) makes sure both sides are ready and agree on initial sequence numbers.
- Sequence numbers: every byte is numbered, so the receiver can reorder segments and discard duplicates.
- Acknowledgements: the receiver sends a cumulative ACK with the next expected byte number.
- Retransmission: if the ACK does not arrive before the retransmission timeout (RTO), the segment is sent again; three duplicate ACKs trigger fast retransmit.
- Checksum: the receiver discards corrupted segments; since no ACK comes back, the sender retransmits them.
- Flow control: the window size in the ACK stops the sender from overflowing the receiver's buffer.
- Congestion control: slow start, congestion avoidance and fast recovery reduce the sending rate when the network is congested.
- Connection termination: FIN/ACK exchange ensures all data is delivered before closing.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Client-server vs peer-to-peer · Computer Networks and Security, chapter 1
- Features of client/server architecture · Computer Networks and Security, chapter 1
- HTTP request served by server · Computer Networks and Security, chapter 6
- Reliable client-server communication · Distributed System, chapter 9
- Architecture before specification; client-server · Software Engineering, chapter 3
- Client-side versus server-side scripting · Web Technology, chapter 3 · asked 3×
- Short note: Client-Server and Master-Slave · Big Data Technologies, chapter 1