-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Binding to an UDP socket on an IPv6 address will fail unless an explicit AF_INET6 setting is passed to constructor. This is not required for TCP, only UDP:
% ruby -v
jruby 9.1.14.0 (2.3.3) 2017-11-08 2176f24 Java HotSpot(TM) 64-Bit Server VM 25.111-b14 on 1.8.0_111-b14 +jit [darwin-x86_64]
Test script:
require "socket"
IPv4 = "127.0.0.1"
IPv6 = "::1"
PORT = 9999
begin
puts "1) binding in IPv4 TCP..."
s4 = TCPServer.open IPv4, PORT
puts "=> OK"
rescue => e
$stderr.puts "#{e.class}: #{e}"
end
begin
puts "2) binding in IPv6 TCP..."
s4 = TCPServer.open IPv6, PORT
puts "=> OK"
rescue => e
$stderr.puts "#{e.class}: #{e}"
end
begin
puts "3) binding in IPv4 UDP..."
s4 = UDPSocket.new
s4.bind IPv4, PORT
puts "=> OK"
rescue => e
$stderr.puts "#{e.class}: #{e}"
end
begin
puts "4) binding in IPv6 UDP..."
s4 = UDPSocket.new
s4.bind IPv6, PORT
puts "=> OK"
rescue => e
$stderr.puts "#{e.class}: #{e}"
end
begin
puts "5) binding in IPv6 UDP w/ AF_INET6..."
s5 = UDPSocket.new(Socket::AF_INET6)
s5.bind IPv6, PORT
puts "=> OK"
rescue => e
$stderr.puts "#{e.class}: #{e}"
endResults in:
1) binding in IPv4 TCP...
=> OK
2) binding in IPv6 TCP...
=> OK
3) binding in IPv4 UDP...
=> OK
4) binding in IPv6 UDP...
Java::JavaNioChannels::UnsupportedAddressTypeException:
5) binding in IPv6 UDP w/ AF_INET6...
=> OK
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels