4

My UDP socket is bind()ing to port 53 (DNS). Does UDP have a TIME_WAIT state or is using SO_REUSEADDR pointless on UDP sockets?

dongle26
  • 826
  • 1
  • 10
  • 18
  • Why are you binding a UDP socket? If it is needed maybe you need to use TCP – Adrian Cornish Sep 22 '12 at 03:34
  • 1
    @Adrian Cornish How else do you tell the OS what port your UDP server is listening on? – Barmar Sep 22 '12 at 03:37
  • 1
    You seem to be talking about a client, this is about a server. For instance, an NTP server must bind to port 123. – Barmar Sep 22 '12 at 03:43
  • Here is the explanation of use case: http://stackoverflow.com/questions/775638/using-so-reuseaddr-what-happens-to-previously-open-socket – Serge Sep 22 '12 at 03:46

1 Answers1

7

UDP doesn't have connections, so there's nothing analogous to TIME_WAIT. You don't need to use SO_REUSEADDR.

If you're listening on a broadcast or multicast address, you might need to use SO_REUSEPORT, so that if there are multiple listeners on the same machine they don't conflict. However, from what I can tell, this doesn't exist on Linux.

Barmar
  • 741,623
  • 53
  • 500
  • 612