The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+20 votes
2.3k views

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
asked in Computer Networks by Veteran (101k points) | 2.3k views
0

3 Answers

+21 votes
Best answer
C is ans listen converts unconnected socket into passive coonect i.e it is waiting for request from client
answered by Boss (31.6k points)
selected by
+13
Listen announces the willingness to accept the connection while Accept passively establishes an incomming connection
0
give some reference for this socket API functions ??
+4
+4

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()

+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: http://linux.die.net/man/2/listen

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


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

39,440 questions
46,623 answers
139,377 comments
57,025 users