in Computer Networks edited by
15,032 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}$
in Computer Networks edited by
by
15.0k views

3 Comments

Calling other connect means just connecting to different port.
10
10
A connected UDP Socket delivers datagrams at a specific port no. So, it need multiple connections to communicate with multiple peers.
0
0

The distinction is between connected and unconnected sockets. An unconnected socket can be used to communicate with any host; but a connected socket, because it has a dedicated destination, can send data to, and receive data from, only one host.

https://www.ibm.com/docs/en/zos/2.2.0?topic=services-typical-udp-socket-session 

2
2

3 Answers

40 votes
40 votes
Best answer

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
by

4 Comments

Can a connected TCP socket be used to communicate with multiple peers simultaneously????
0
0

same doubt as  !

0
0

Source

  • Using the CONNECT command on a UDP socket does not change the UDP protocol from a connectionless to a connection-based protocol. The UDP socket remains connectionless. The primary benefit of using connected UDP sockets is to limit communication with a single remote application.
  • When a UDP socket becomes a connected UDP socket, it can no longer use the SENDTO and RECVFROM commands. Connected UDP sockets use the socket commands READ, WRITE, SEND, or RECV to communicate with the remote peer, instead of using the SENTO and RECVFROM commands.
0
0
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