Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIX socket API.
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:
- socket(): Creates an endpoint for communication (not listed in the options but occurs first).
- bind(): Assigns a local IP address and port number to the socket.
- listen(): Marks the socket as a passive socket that will be used to accept incoming connection requests.
- 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.
- 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.
