Project

General

Profile

Actions

Bug #5525

closed

UDPSocket#bind(ip, port) fails under IPv6 => Errno::EAFNOSUPPORT

Added by ibc (Iñaki Baz Castillo) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
-
Backport:
[ruby-core:40562]

Description

This bug can be reproduced in Ruby 1.8 as well.

The following script shows that UDPSocket#bind fails (Errno::EAFNOSUPPORT) if the given IP is IPv6 (however TCPServer does not fail).

My computer has IPv4 and IPv6 (using Miredo/Teredo). The script:


require "socket"

IPv4 = "192.168.1.12"
IPv6 = "2001:0:53aa:64c:187c:3ecb:2419:d1a6"
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

Result of the script:


  1. binding in IPv4 TCP...
    => OK

  2. binding in IPv6 TCP...
    => OK

  3. binding in IPv4 UDP...
    => OK

  4. binding in IPv6 UDP...
    Errno::EAFNOSUPPORT: Address family not supported by protocol - bind(2)


Tested with:

  • ruby 1.9.3dev (2011-07-31 revision 32789) [x86_64-linux]
  • ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
  • ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0