128k views
5 votes
When does blocking connect() return, how long does it take?

A. It returns immediately.
B. It returns when the connection is established, and the duration depends on the network.
C. It returns after a fixed time interval, regardless of the connection status.
D. It returns when the connection is refused by the remote socket..

1 Answer

4 votes

Final answer:

A blocking connect() call returns when the connection is established, with the timing being dependent on network conditions; it does not return immediately, after a fixed interval, and not only on refusal by the remote socket.

Step-by-step explanation:

When a blocking connect() function is called in socket programming, it returns when the connection is established, and the duration depends on the network conditions.

Therefore, the correct answer to when blocking connect() returns is B. It does not return immediately, which eliminates option A. It is network dependent, which means it does not return after a fixed time interval, disregarding options C. While a connection refusal does cause the blocking connect() to return, it is not the only case when it returns, thus option D is only partially correct.

User Wayne B
by
8.7k points