GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 59

TCP connect before the server calls accept

Computer Networks · Transport, Congestion Control & Traffic Shaping · Full GATE CSE 2008 paper

GATE 2008, Q59 2 marks · MCQ
Report issue

Transport, Congestion Control & Traffic Shaping

Question 59, GATE 2008: A TCP server executes socket(), bind(), listen(), then is preempted before any accept(). A client executes socket() and connect() to it. Which event can occur in the intended normal setting?

(A) connect() returns successfully
(B) connect() blocks
(C) connect() returns an error
(D) connect() causes a core dump
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The client connect() can return successfully, option A. After socket(), bind() and listen(), the server kernel has a listening TCP endpoint and can complete the three-way handshake while the server process is descheduled.
2. The resulting established connection waits in the listener’s accept queue; accept() subsequently removes an entry and returns a connected socket to the server process. Hence user-space accept() is not required for the client handshake to complete.
3. The intended setting assumes an available backlog slot and normal network operation; incidental loss, queue exhaustion or unrelated errors can of course affect real calls.

Original paper, page 11