Skip to content

GATE CS 2017 Set 2 Q18 — Transport Layer: Flow Control, Congestion Control, UDP, TCP, Sockets

Explain with AI

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.
Choose one option
View worked solution

Answer: B

To understand the behavior of a connected UDP socket in Linux, let us analyze both statements:

  • Statement I: "A connected UDP socket can be used to communicate with multiple peers simultaneously."
    Incorrect. When connect() is called on a UDP socket, the operating system kernel binds the socket to a specific remote IP address and port number. Consequently:
    • The socket can only send datagrams to this specific peer (using write() or send() instead of sendto()).
    • The socket will only receive datagrams originating from this specific peer; datagrams from any other source are discarded by the kernel.
    Thus, it cannot be used to communicate with multiple peers simultaneously.

  • Statement II: "A process can successfully call connect function again for an already connected UDP socket."
    Correct. Unlike TCP, where a connection is established via a three-way handshake and cannot be re-connected, UDP is connectionless. Calling connect() on a UDP socket simply updates the destination association in the kernel. A process can call connect() again to:
    • Specify a new peer (changing the destination IP/port).
    • Disconnect the socket entirely by setting the address family to AF_UNSPEC.

Therefore, only Statement II is correct.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Transport Layer: Flow Control, Congestion Control, UDP, TCP, Sockets questions