Project

General

Profile

Actions

Bug #3787

closed

TCPSocket.new() fails on IPv6 connections for IPV4/IPv6 hosts

Added by adamm (Adam Majer) about 14 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]
Backport:
[ruby-core:32055]

Description

=begin
$ host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1


server setup is just listening to ::1 address,

require 'socket'
s = TCPServer.new( '::1', 1200 )
s.accept


then I try to connect to this with client socket,

irb(main):001:0> require 'socket'
=> true
irb(main):002:0> TCPSocket.new( 'localhost', 1200 )
Errno::ECONNREFUSED: Connection refused - connect(2)
from (irb):2:in initialize' from (irb):2:in new'
from (irb):2
from :0
irb(main):003:0> TCPSocket.new( '::1', 1200 )
=> #TCPSocket:0x7f54d1c0aeb8

Clearly, the 'localhost' should try to iterate through the addresses until it can connect, not fail. Python works correctly. telnet as well,

$ telnet localhost 1200
Trying ::1...
Connected to localhost.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0