AMU 2026 Computer PYQ — Consider socket API on a Linux machine that supports connected UD… | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
AMU 2026 — Computer PYQ
AMU | Computer | 2026
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?
I. A process can successfully call connect function again for an already connected UDP socket.
II. A connected UDP socket can be used to communicate with multiple peers simultaneously.
Choose the correct answer:
A.
I only
(Correct Answer)
B.
II only
C.
Both I and II
D.
Neither I nor II
Correct Answer:
I only
Explanation
Statement I is CORRECT: Unlike a TCP socket, where a connection is permanent once established, a UDP socket is connectionless. When you call connect() on a UDP socket, the kernel simply binds a specific remote IP address and port number to that socket descriptor. A process can call connect() again on an already connected UDP socket to:
Change the remote peer to a new address.
Disconnect the socket by setting the address family to AF_UNSPEC.
Statement II is INCORRECT: Once connect() is called on a UDP socket, it restricts the socket to only send datagrams to and receive datagrams from that specific peer address. Therefore, it cannot be used to communicate with multiple peers simultaneously. To communicate with a different peer, the socket must either re-call connect() to specify a new destination or use an unconnected socket with sendto() and recvfrom().
Explanation
Statement I is CORRECT: Unlike a TCP socket, where a connection is permanent once established, a UDP socket is connectionless. When you call connect() on a UDP socket, the kernel simply binds a specific remote IP address and port number to that socket descriptor. A process can call connect() again on an already connected UDP socket to:
Change the remote peer to a new address.
Disconnect the socket by setting the address family to AF_UNSPEC.
Statement II is INCORRECT: Once connect() is called on a UDP socket, it restricts the socket to only send datagrams to and receive datagrams from that specific peer address. Therefore, it cannot be used to communicate with multiple peers simultaneously. To communicate with a different peer, the socket must either re-call connect() to specify a new destination or use an unconnected socket with sendto() and recvfrom().