Skip to content

Commit 0af7680

Browse files
committed
Use port number 0 for ephemeral port
Hopefully RFC-6056 is being applied. Fixes #63.
1 parent 5880fd4 commit 0af7680

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

lib/resolv.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,8 @@ def self.free_request_id(host, port, id) # :nodoc:
660660
end
661661

662662
def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
663-
begin
664-
port = random(1024..65535)
665-
udpsock.bind(bind_host, port)
666-
rescue Errno::EADDRINUSE, # POSIX
667-
Errno::EACCES, # SunOS: See PRIV_SYS_NFS in privileges(5)
668-
Errno::EPERM # FreeBSD: security.mac.portacl.port_high is configurable. See mac_portacl(4).
669-
retry
670-
end
663+
# Simply use 0 with assuming RFC-6056 is applied.
664+
udpsock.bind(bind_host, 0)
671665
end
672666

673667
class Requester # :nodoc:

0 commit comments

Comments
 (0)