Actions
Feature #19064
openUDPSocket#bind does not take AddrInfo, despite documentation saying it should
Status:
Open
Assignee:
-
Target version:
-
Description
https://docs.ruby-lang.org/en/master/Socket.html#method-i-bind says that this code should work:
require 'socket'
# use Addrinfo
socket = Socket.new(:INET, :STREAM, 0)
socket.bind(Addrinfo.tcp("127.0.0.1", 2222))
p socket.local_address #=> #<Addrinfo: 127.0.0.1:2222 TCP>
and it does, but UDPSocket does not like Addrinfo:
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:
#<Addrinfo: fe80::f58e:d5ea:41e0:2555%eth0>
Seen on versions back to 2.6.6, but tested with ruby-head to be sure.
Actions
Like0
Like0Like0