🎓 BookMCQ
← Back to 25. Introduction to Application Layer

📝 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.
3
Easy
5
Medium
2
Hard

📝 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?

A.SYN‑ACK
B.FIN
C.RST
D.ACK ✅
💡 Difficulty: easy | ✅ Correct: D

📖 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?

A.Faster connection establishment
B.Increased unnecessary retransmissions ✅
C.Larger congestion window
D.Reduced packet loss
💡 Difficulty: medium | ✅ Correct: B

📖 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 2322^{32} bytes have been transmitted, what happens to the sequence numbers and how must a receiver handle this condition?

A.Sequence numbers wrap to zero, requiring the receiver to use relative numbering ✅
B.Connection is terminated
C.Duplicate ACKs are generated
D.Window size is reset
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: When 2322^{32} 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?

A.Both guarantee ordered delivery
B.TCP is connectionless
C.TCP provides reliability through acknowledgments and retransmissions ✅
D.UDP uses three‑way handshake
💡 Difficulty: easy | ✅ Correct: C

📖 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?

A.It buffers small segments until a larger segment can be sent ✅
B.It forces immediate transmission of every segment
C.It disables retransmission
D.It expands the receive window
💡 Difficulty: medium | ✅ Correct: A

📖 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?

A.Fast retransmit occurs only after a connection reset
B.Timeout retransmission uses duplicate ACKs
C.Both rely on the same timer
D.Fast retransmit triggers after three duplicate ACKs, while timeout occurs after the retransmission timer expires ✅
💡 Difficulty: hard | ✅ Correct: D

📖 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?

A.SYN
B.FIN ✅
C.PSH
D.URG
💡 Difficulty: easy | ✅ Correct: B

📖 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?

A.Throughput is independent of window size
B.Smaller windows increase throughput
C.Throughput ≈ Window Size ÷ RTT ✅
D.Window size only affects latency
💡 Difficulty: medium | ✅ Correct: C

📖 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?

A.Loop until the total bytes received equals the advertised Content‑Length ✅
B.Assume a single read returns the whole file
C.Close the socket after the first read
D.Ignore the Content‑Length header
💡 Difficulty: medium | ✅ Correct: A

📖 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?

A.Transfer Control Process
B.Transmission Connection Protocol
C.Transmission Control Protocol ✅
D.Transport Communication Procedure
💡 Difficulty: medium | ✅ Correct: C

📖 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.

🔗 Related Topics (MCQs)