StreakPeaked· Practice

ExamsGATETechnical

A client process P needs to make a TCP connection to a server process S. Consider the following situation: the server process S executes a socket(), a bind(), and a listen() system call in that order, following which it is preempted. Subsequently, the client process P executes a socket() system call followed by connect() system call to connect to the server process S. The server process has not executed any accept() system call. Which one of the following events could take place?

  1. connect() system call returns successfully
  2. connect() system call blocks
  3. connect() system call returns an error
  4. connect() system call results in a core dump

Correct answer: connect() system call returns successfully

Solution

The connect() system call can return successfully because the client can establish a connection to the server's listening socket, even if the server has not yet called accept(). The connection is established in a half-open state, allowing the client to proceed.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →