34 votes 34 votes Which of the following socket API functions converts an unconnected active TCP socket into a passive socket? $\textsf{connect}$ $\textsf{bind}$ $\textsf{listen}$ $\textsf{accept}$ Computer Networks gatecse-2014-set2 computer-networks sockets easy + – go_editor asked Sep 28, 2014 • edited Jun 21, 2021 by Lakshman Bhaiya go_editor 11.2k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply vijay_jr commented Jan 3, 2018 reply Follow Share References : 1) http://soft.vub.ac.be/~tvcutsem/distsys/sockets.pdf 2) http://www.csd.uoc.gr/~hy556/material/tutorials/cs556-3rd-tutorial.pdf 4 votes 4 votes Overflow04 commented Nov 14, 2022 reply Follow Share https://www.cse.iitk.ac.in/users/dheeraj/cs425/lec18.html 2 votes 2 votes Please log in or register to add a comment.
Best answer 35 votes 35 votes (C) is answer $\textsf{listen}$ converts unconnected socket into passive $\textsf{connect}$ i.e it is waiting for request from client. Pooja Palod answered Aug 19, 2015 • edited Jun 21, 2021 by Lakshman Bhaiya Pooja Palod comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments Ayush Upadhyaya commented Aug 13, 2018 reply Follow Share 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() 74 votes 74 votes Kuldeep Pal commented Dec 23, 2018 reply Follow Share best ans ayush 2 votes 2 votes Twinkle Shukla commented Jul 12, 2020 reply Follow Share Thanku Ayush sir 1 votes 1 votes Please log in or register to add a comment.
17 votes 17 votes connect This system call sends SYN packets — it does something, so active. bind This system call binds the local machine's IP and port address to the socket — it does something, so active. listen This system call just makes the machine wait for someone to send a SYN packet — clearly passive. accept This system call sends ACK in response to SYN packets — it does something, so active. Option C JashanArora answered Dec 23, 2019 JashanArora comment Share Follow See all 0 reply Please log in or register to add a comment.
3 votes 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 Regina Phalange answered Apr 3, 2017 Regina Phalange comment Share Follow See all 0 reply Please log in or register to add a comment.