Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIX socket API.
(A) listen, accept, bind recv
(B) bind, listen, accept, recv
(C) bind, accept, listen, recv
(D) accept, listen, bind, recv
Explanation: bind, listen, accept and recv are server side socket API functions.
bind() associates a socket with a socket address structure, i.e. a specified local port number and IP address. listen() causes a bound TCP socket to enter listening state. accept() accepts a received incoming attempt to create a new TCP connection from the remote client, recv() is used to receive data from a remote socket.
A server must first do bind() to tell operating system the port number on which it would be listing, then it must listen to receive incoming connection requests on the bound port number. Once a connection comes, the server accepts using accept(), then starts receiving data using recv().
Quiz of this Question