📝 Iterative Communication Using TCP (10 MCQs)
Sequential Client Handling over a Reliable Stream
An iterative TCP server accepts a connection, communicates with that client, closes the connected socket, and then accepts another client. Only one accepted client is actively handled by the server's main processing loop at a time. TCP provides a reliable ordered byte stream, but the application must define its own message boundaries. Other connection requests can wait in the operating system's pending queue.
Listening and Connected Socket Roles
A TCP server creates a stream socket, binds it to a service port, and calls listen to prepare for connection requests. Each successful accept returns a new connected socket for one client, while the original listening socket remains available. A client calls connect to establish the connection with the server endpoint.
Connection Setup and Sequential Data Exchange
TCP establishes a connection through a three-way handshake before normal data transfer. The server accepts the connection, receives request bytes, processes them, and sends response bytes. After the exchange, either endpoint may close its side of the connection. The server then returns to accept and waits for another client. The handshake synchronizes initial sequence numbers and confirms bidirectional reachability.
Two Clients Served in Sequence
Suppose client A connects first and sends a calculation request. The server accepts A, reads its data, returns the result, and closes A's connected socket. Only then does it accept client B. If A remains connected while waiting, B may remain in the pending connection queue until the server is ready.
Reliability Does Not Make the Server Concurrent
TCP manages byte sequencing, acknowledgments, retransmission, and receiver flow control, but it does not decide how many application clients a server processes simultaneously. An iterative design is simple and suitable for short tasks. A long calculation or slow client can occupy the service loop and increase waiting time for other clients.
Misconceptions About Iterative TCP Servers
'The listening socket carries every client conversation' is incorrect because accept returns a separate connected socket. 'TCP sends one complete message per receive call' ignores stream semantics. 'A TCP server is automatically concurrent' is also false: concurrency requires additional threads, processes, asynchronous I/O, or another scheduling design. The design remains sequential unless the program explicitly schedules concurrent handlers.
Following Listen, Accept and Connection Closure
Know the sequence socket, bind, listen, accept, receive or read, send or write, and close. Explain why the server retains its listening socket after a client disconnects, and identify how the three-way handshake establishes TCP state. Compare iterative handling with concurrent designs and recognize the delay caused by a slow client.
TCP Iterative Server Terms
- Listening socket - TCP endpoint waiting for connection requests.
- accept - Returns a connected socket for a client.
- connect - Starts a TCP connection to a server.
- Three-way handshake - Synchronizes TCP connection state between peers.
- Byte stream - Ordered sequence without preserved message boundaries.
- Backlog - Queue limit for pending connection requests.
📝 All Iterative Communication Using TCP MCQs
Q1. In TCP's iterative communication, after a client sends a SYN and receives a SYN‑ACK from the server, what is the next packet the client must transmit?
📖 Explanation: The client must send an ACK to acknowledge the server's SYN‑ACK, completing the three‑way handshake. This ACK confirms receipt of the server’s sequence number and signals that the connection is now established, allowing data exchange to begin.
Q2. If the timeout interval for a TCP segment is configured too low, which effect is most likely to be observed during iterative communication?
📖 Explanation: A timeout that is too short causes the sender to assume loss prematurely, prompting retransmission of segments that may still be in flight. This leads to duplicate packets, wasted bandwidth, and can trigger unnecessary congestion control measures.
Q3. TCP uses a 32‑bit sequence number field. After exactly bytes have been transmitted, what happens to the sequence numbers and how must a receiver handle this condition?
📖 Explanation: When bytes are sent, the 32‑bit sequence number rolls over to zero. Receivers must interpret sequence numbers relative to the initial value, using modulo arithmetic, to avoid ambiguity and correctly reassemble the byte stream despite the wrap‑around.
Q4. Which of the following best contrasts TCP's iterative communication with UDP's datagram delivery?
📖 Explanation: TCP establishes a connection and uses acknowledgments, sequencing, and retransmission to ensure reliable, ordered delivery, whereas UDP sends independent datagrams without such guarantees, making TCP suitable for applications needing dependable data transfer.
Q5. How does Nagle's algorithm influence the latency of small packets in TCP's iterative communication?
📖 Explanation: Nagle's algorithm coalesces multiple small segments into a single larger packet, holding back transmission until enough data accumulates or an acknowledgment arrives. This reduces the number of packets but can increase latency for latency‑sensitive, small‑message traffic.
Q6. In the context of iterative TCP communication, what distinguishes fast retransmit from timeout‑based retransmission?
📖 Explanation: Fast retransmit is activated when the sender receives three duplicate ACKs, indicating a likely loss, and it resends the missing segment immediately. Timeout‑based retransmission waits for the retransmission timer to expire, which can be slower and less responsive.
Q7. During an iterative TCP session, which flag is used to gracefully terminate the connection?
📖 Explanation: The FIN flag signals the intention to close a TCP connection. When one side sends a FIN, the peer acknowledges it and may also send its own FIN, completing a graceful shutdown that ensures all pending data is transmitted before the connection is fully closed.
Q8. What relationship does the TCP sliding window size have with achievable throughput in an iterative communication scenario?
📖 Explanation: Throughput in TCP is roughly the window size divided by the round‑trip time (RTT). A larger window permits more unacknowledged data to be in flight, raising potential throughput, provided the network can accommodate the increased volume without congestion.
Q9. When implementing a simple client that iteratively reads a file over TCP, which step is essential to correctly handle partial reads?
📖 Explanation: TCP does not guarantee that a single read will return the entire file. The client must repeatedly read from the socket, accumulating bytes until the number received matches the Content‑Length value advertised by the server, ensuring complete and accurate file retrieval.
Q10. What does the acronym TCP stand for?
📖 Explanation: TCP stands for Transmission Control Protocol, which provides reliable, ordered, and error‑checked delivery of a stream of bytes between applications running on hosts communicating via an IP network.