Skip to content

GATE CS 2015 Set 2 Q20 — Transport Layer: Flow Control, Congestion Control, UDP, TCP, Sockets

Explain with AI

Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIX socket API.

Choose one option
View worked solution

Answer: B

To establish a connection-oriented (TCP) server using the UNIX socket API, the server process must perform the following steps in order:

  1. socket(): Creates an endpoint for communication (not listed in the options but occurs first).
  2. bind(): Assigns a local IP address and port number to the socket.
  3. listen(): Marks the socket as a passive socket that will be used to accept incoming connection requests.
  4. accept(): Blocks the server until a connection request arrives. It then extracts the first connection request on the queue of pending connections and creates a new connected socket.
  5. recv(): Receives data from the connected socket.

Therefore, the correct sequence of invocation is:

bind → listen → accept → recv

This matches Option B.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Transport Layer: Flow Control, Congestion Control, UDP, TCP, Sockets questions