CS FundamentalsHardGATE CS · Product company CS fundamentals

A UDP server and a TCP server are written with BSD sockets. Which statement is correct?

  1. A. Both servers call listen() and accept() before receiving data
  2. B. Only the UDP server needs bind(); a TCP server gets a port from accept()
  3. C. Only the TCP server calls listen() and accept(); the UDP server binds and calls recvfrom()
  4. D. The TCP server calls connect() to wait for clients

Correct answer: C. Only the TCP server calls listen() and accept(); the UDP server binds and calls recvfrom()

listen() turns a TCP socket into a passive one and accept() returns a new connected socket per client. UDP is connectionless: after bind() to a port the server reads datagrams with recvfrom(), learning each sender's address from it. connect() is the client's call.

More Computer Networks questions

Exams that ask this topic