From: "mcr (Michael Richardson)" Date: 2022-10-17T00:50:45+00:00 Subject: [ruby-core:110325] [Ruby master Bug#19064] UDPSocket#bind does not take AddrInfo, despite documentation saying it should Issue #19064 has been reported by mcr (Michael Richardson). ---------------------------------------- Bug #19064: UDPSocket#bind does not take AddrInfo, despite documentation saying it should https://bugs.ruby-lang.org/issues/19064 * Author: mcr (Michael Richardson) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0dev (2022-10-16T09:31:08Z master ba9c0d0b9f) [x86_64-linux * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- https://docs.ruby-lang.org/en/master/Socket.html#method-i-bind says that this code should work: ``` ruby require 'socket' # use Addrinfo socket = Socket.new(:INET, :STREAM, 0) socket.bind(Addrinfo.tcp("127.0.0.1", 2222)) p socket.local_address #=> # ``` and it does, but UDPSocket does *not* like Addrinfo: ``` ruby socket = UDPSocket.new(Socket::AF_INET6) ai=Addrinfo.udp("127.0.0.1", 2224) socket.bind(ai, 0) ```` A reason to use an Addrinfo rather than a string is because it came from, for instance, Socket.getifaddrs, and might have scope and other information attached, like: ``` ruby # ``` Seen on versions back to 2.6.6, but tested with ruby-head to be sure. -- https://bugs.ruby-lang.org/ Unsubscribe: