edited by
14,965 views
47 votes
47 votes

Consider socket API on a Linux machine that supports connected UDP sockets. A connected UDP socket is a UDP socket on which connect function has already been called. Which of the following statements is/are CORRECT?

  1. A connected UDP socket can be used to communicate with multiple peers simultaneously.
  2. A process can successfully call connect function again for an already connected UDP socket.
  1. $\text{I}$ only
  2. $\text{II}$ only
  3. Both $\text{I}$ and $\text{II}$
  4. Neither $\text{I}$ nor $\text{II}$
edited by

3 Answers

Best answer
40 votes
40 votes

Calling $\text{connect}$ Multiple Times for a UDP Socket

A process with a connected UDP socket can call $\text{connect}$ again for that socket for one of two reasons:

  1. To specify a new IP address and port
  2. To unconnect the socket

The first case specifying a new peer for a connected UDP socket differs from the use of $\text{connect}$ with a TCP socket. Connect can be called only one time for a TCP socket. To unconnect a UDP socket. we call Connect but set the family member of the socket address structure to $\text{AT_UNSPEC}.$

Also, a UDP client or server can call Connect only if that process uses the UDP socket to communicate with exactly one peer.

So, option B should be the answer.

For $1^{\text{st}}$ part if "NOT connected" then it'll be true http://stackoverflow.com/questions/3329641/how-do-multiple-clients-connect-simultaneously-to-one-port-say-80-on-a-server

edited by
10 votes
10 votes
Even if UDP is connectionless, every UDP socket has a single specified IP number and port number to connect to. Therefore we can not use same socket to connect to multiple peers simultaneously.
2 votes
2 votes
I think it should be b)

 They are talking about socket which is combination of ip address and port address
Answer:

Related questions

44 votes
44 votes
3 answers
2
khushtak asked Feb 14, 2017
16,328 views
The maximum number of $\textsf{IPv4}$ router addresses that can be listed in the record route (RR) option field of an $\textsf{IPv4}$ header is______.