The Gateway to Computer Science Excellence
+20 votes

Which of the following socket API functions converts an unconnected active TCP socket into a passive socket?

  1. connect
  2. bind
  3. listen
  4. accept
in Computer Networks by Veteran (105k points) | 3.5k views

3 Answers

+25 votes
Best answer

(C) is ans listen converts unconnected socket into passive connect i.e it is waiting for request from client

by Boss (31.2k points)
edited by
Listen announces the willingness to accept the connection while Accept passively establishes an incomming connection
give some reference for this socket API functions ??

Focus on the words of the question and if you know the basics of the socket, it is easy to answer.

Unconnected active TCP socket into a passive socket.

"Unconnected" means till now no connection has been established.

"Active" means the socket has been created, and socket will become active only when it is binded to the local machine's IP and port address(in this case machine is server) using bind() system call.

"into a passive socket"-We already must have listened to these terms like passive(something in which no initiative is taken) and active(in which initiative is taken). Passive socket is one which is ready to accept the connections from the client.

So now, you call listen() system call on the server side which informs the transport layer that it is ready to accept connections from the clients.

So, combining all,

First, you must have called socket() to create the socket

then bind() to bind the IP address and port to this newly created socket and now this socket becomes active.

Now I want this to listen to client requests, so I call listen()

best ans ayush
+3 votes

listen() marks the socket referred to by sockfd as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept(). Source:

by Loyal (9.6k points)
–10 votes
ans b)
by Loyal (5.2k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,458 answers
100,252 users