ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:64769] [ruby-trunk - Bug #10203] [Open] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
@ 2014-09-04 15:20 ` lucas
  2014-09-05  7:07 ` [ruby-core:64785] [ruby-trunk - Bug #10203] " naruse
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-09-04 15:20 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been reported by Lucas Nussbaum.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203

* Author: Lucas Nussbaum
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:64785] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
  2014-09-04 15:20 ` [ruby-core:64769] [ruby-trunk - Bug #10203] [Open] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname lucas
@ 2014-09-05  7:07 ` naruse
  2014-09-05  7:25 ` [ruby-core:64786] " lucas
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: naruse @ 2014-09-05  7:07 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Yui NARUSE.


I know you was Debian porter, but show the actual ruby -v

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-48675

* Author: Lucas Nussbaum
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:64786] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
  2014-09-04 15:20 ` [ruby-core:64769] [ruby-trunk - Bug #10203] [Open] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname lucas
  2014-09-05  7:07 ` [ruby-core:64785] [ruby-trunk - Bug #10203] " naruse
@ 2014-09-05  7:25 ` lucas
  2014-09-05  9:12 ` [ruby-core:64788] " lucas
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-09-05  7:25 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


that was from the Debian package indeed. I haven't rebuilt Ruby from source. The Debian package does not carry any Debian-specific patch at the moment. You cannot reproduce it?

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-48676

* Author: Lucas Nussbaum
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:64788] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-09-05  7:25 ` [ruby-core:64786] " lucas
@ 2014-09-05  9:12 ` lucas
  2014-10-13  6:59 ` [ruby-core:65646] [ruby-trunk - Bug #10203] [Feedback] " akr
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-09-05  9:12 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


Also, a colleague using Arch Linux checked (using the same Ruby version). He doesn't have IPv6 enabled.

And he also got the "TypeError: no implicit conversion of nil into String" exception instead of the Errno::EADDRINUSE one.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-48678

* Author: Lucas Nussbaum
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65646] [ruby-trunk - Bug #10203] [Feedback] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-09-05  9:12 ` [ruby-core:64788] " lucas
@ 2014-10-13  6:59 ` akr
  2014-10-13  7:10 ` [ruby-core:65647] [ruby-trunk - Bug #10203] " lucas
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-10-13  6:59 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Akira Tanaka.

Status changed from Open to Feedback

It doesn't reproduce on my environment.

```
% lsb_release -idrc
Distributor ID:	Debian
Description:	Debian GNU/Linux testing (jessie)
Release:	testing
Codename:	jessie
% bin/irb          
irb(main):001:0> RUBY_VERSION
=> "2.2.0"
irb(main):002:0> require 'socket'
=> true
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
irb(main):004:0> TCPServer::new(10001)
Errno::EADDRINUSE: Address already in use - bind(2) for nil port 10001
	from (irb):4:in `initialize'
	from (irb):4:in `new'
	from (irb):4
	from bin/irb:11:in `<main>'
irb(main):005:0> 
```

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49378

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65647] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-10-13  6:59 ` [ruby-core:65646] [ruby-trunk - Bug #10203] [Feedback] " akr
@ 2014-10-13  7:10 ` lucas
  2014-10-13  8:32   ` [ruby-core:65657] " Eric Wong
  2014-10-13  8:40 ` [ruby-core:65658] " normalperson
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 16+ messages in thread
From: lucas @ 2014-10-13  7:10 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


It might be fixed in Ruby 2.2... I don't have an easy way to test. Akira, do you have an easy way to test with Ruby 2.1?

If it is indeed fixed, it might be worth backporting to 2.1.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49379

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65657] Re: [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
  2014-10-13  7:10 ` [ruby-core:65647] [ruby-trunk - Bug #10203] " lucas
@ 2014-10-13  8:32   ` Eric Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Wong @ 2014-10-13  8:32 UTC (permalink / raw
  To: Ruby developers

lucas@lucas-nussbaum.net wrote:
> It might be fixed in Ruby 2.2... I don't have an easy way to test. Akira, do you have an easy way to test with Ruby 2.1?
> 
> If it is indeed fixed, it might be worth backporting to 2.1.

It may be fixed in trunk r44497.
Lucas: can you apply on your end and confirm?  Thanks.

commit 5b0fb1aaddad03e111606e0d0eaf8ed9c9f7b0b6
Author: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date:   Sat Jan 4 10:15:31 2014 +0000

    socket.c: format flags
    
    * ext/socket/socket.c (rsock_syserr_fail_host_port): use format flags,
      '+' to inspect, ' ' to quote unprintables.
    * ext/socket/socket.c (rsock_syserr_fail_path): ditto.
    * ext/socket/socket.c (rsock_syserr_fail_raddrinfo): ditto.
    
    git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65658] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-10-13  7:10 ` [ruby-core:65647] [ruby-trunk - Bug #10203] " lucas
@ 2014-10-13  8:40 ` normalperson
  2014-10-13  9:01 ` [ruby-core:65660] " akr
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: normalperson @ 2014-10-13  8:40 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Eric Wong.


 lucas@lucas-nussbaum.net wrote:
 > It might be fixed in Ruby 2.2... I don't have an easy way to test. Akira, do you have an easy way to test with Ruby 2.1?
 > 
 > If it is indeed fixed, it might be worth backporting to 2.1.
 
 It may be fixed in trunk r44497.
 Lucas: can you apply on your end and confirm?  Thanks.
 
 commit 5b0fb1aaddad03e111606e0d0eaf8ed9c9f7b0b6
 Author: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
 Date:   Sat Jan 4 10:15:31 2014 +0000
 
     socket.c: format flags
     
     * ext/socket/socket.c (rsock_syserr_fail_host_port): use format flags,
       '+' to inspect, ' ' to quote unprintables.
     * ext/socket/socket.c (rsock_syserr_fail_path): ditto.
     * ext/socket/socket.c (rsock_syserr_fail_raddrinfo): ditto.
     
     git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49389

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65660] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-10-13  8:40 ` [ruby-core:65658] " normalperson
@ 2014-10-13  9:01 ` akr
  2014-10-13 11:37 ` [ruby-core:65667] " lucas
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-10-13  9:01 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Akira Tanaka.


Hm.

Ruby 2.1.3 causes the wrong error message:

```
% ./ruby -vrsocket -e 'p TCPServer::new(10001); p TCPServer::new(10001)'
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
#<TCPServer:fd 7>
-e:1:in `initialize': no implicit conversion of nil into String (TypeError)
	from -e:1:in `new'
	from -e:1:in `<main>'
```

However it doesn't succeed twice.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49391

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65667] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-10-13  9:01 ` [ruby-core:65660] " akr
@ 2014-10-13 11:37 ` lucas
  2014-10-13 11:41 ` [ruby-core:65668] " lucas
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-10-13 11:37 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


I built Ruby 2.2 from source, and still encountered the same problem as the original report, with the exception that the bogus error message seems fixed:
$  ./ruby -vrsocket -e 'p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001)'
ruby 2.2.0dev (2014-10-13 trunk 47902) [x86_64-linux]
#<TCPServer:fd 7>
tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN     
#<TCPServer:fd 8>
tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN     
tcp6       0      0 :::10001                :::*                    LISTEN     
-e:1:in `initialize': Address already in use - bind(2) for nil port 10001 (Errno::EADDRINUSE)
	from -e:1:in `new'
	from -e:1:in `<main>'

I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49399

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65668] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-10-13 11:37 ` [ruby-core:65667] " lucas
@ 2014-10-13 11:41 ` lucas
  2014-10-13 12:41 ` [ruby-core:65671] " akr
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-10-13 11:41 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


correct copy/paste:

    $  ./ruby -vrsocket -e 'p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001)'
    ruby 2.2.0dev (2014-10-13 trunk 47902) [x86_64-linux]
    #<TCPServer:fd 7>
    tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN     
    #<TCPServer:fd 8>
    tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN     
    tcp6       0      0 :::10001                :::*                    LISTEN     
    -e:1:in `initialize': Address already in use - bind(2) for nil port 10001 (Errno::EADDRINUSE)
    	from -e:1:in `new'
    	from -e:1:in `<main>'


----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49400

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65671] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-10-13 11:41 ` [ruby-core:65668] " lucas
@ 2014-10-13 12:41 ` akr
  2014-10-13 16:50 ` [ruby-core:65676] " lucas
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-10-13 12:41 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Akira Tanaka.


It seems net.ipv6.bindv6only affect the behavior.

```
% sudo sysctl net.ipv6.bindv6only=0
net.ipv6.bindv6only = 0
% ./ruby -vrsocket -e 'p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001)'
ruby 2.2.0dev (2014-10-13 trunk 47899) [x86_64-linux]
#<TCPServer:fd 7>
tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN
-e:1:in `initialize': Address already in use - bind(2) for nil port 10001 (Errno::EADDRINUSE)
	from -e:1:in `new'
	from -e:1:in `<main>'
```

```
% sudo sysctl net.ipv6.bindv6only=1
net.ipv6.bindv6only = 1
% ./ruby -vrsocket -e 'p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001); system("netstat -ln|grep 10001"); p TCPServer::new(10001)'
ruby 2.2.0dev (2014-10-13 trunk 47899) [x86_64-linux]
#<TCPServer:fd 7>
tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN
#<TCPServer:fd 8>
tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN
tcp6       0      0 :::10001                :::*                    LISTEN
-e:1:in `initialize': Address already in use - bind(2) for nil port 10001 (Errno::EADDRINUSE)
	from -e:1:in `new'
	from -e:1:in `<main>'
```

This depends on OS configuration.

TCPServer.new doesn't hide this difference because some OS, such as OpenBSD, provides only the latter behavior.

I recommend Socket.tcp_server_sockets.
It returns two sockets for IPv4 and IPv6, regardless of net.ipv6.bindv6only.

```
% sudo sysctl net.ipv6.bindv6only=0
net.ipv6.bindv6only = 0
% ./ruby -rsocket -e 'p Socket.tcp_server_sockets(10001)'
[#<Socket:fd 7>, #<Socket:fd 8>]
% sudo sysctl net.ipv6.bindv6only=1
net.ipv6.bindv6only = 1
% ./ruby -rsocket -e 'p Socket.tcp_server_sockets(10001)'
[#<Socket:fd 7>, #<Socket:fd 8>]
```



----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49403

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65676] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2014-10-13 12:41 ` [ruby-core:65671] " akr
@ 2014-10-13 16:50 ` lucas
  2014-10-13 17:10 ` [ruby-core:65677] " akr
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-10-13 16:50 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


Indeed, bindv6only=1 seems to change this. However, bindv6only=1 is kind-of the default on all systems (except some Linux distros).

My goal was to implement the following:
try to bind port 10001 ; if already taken, bind port 10002
That's not possible with the current behaviour.

I don't think it's an OS behaviour. I straced the ruby process, and saw:

first TCPServer call:
    [pid 16280] bind(7, {sa_family=AF_INET, sin_port=htons(10001), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
second TCPServer call:
    [pid 16280] bind(8, {sa_family=AF_INET, sin_port=htons(10001), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
    [pid 16280] bind(8, {sa_family=AF_INET6, sin6_port=htons(10001), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
third TCPServer call:
    [pid 16280] bind(9, {sa_family=AF_INET, sin_port=htons(10001), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
    [pid 16280] bind(9, {sa_family=AF_INET6, sin6_port=htons(10001), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 EADDRINUSE (Address already in use)

So the second bind() on AF_INET port 10001 fails correctly. It seems that Ruby implements a fallback mechanism that makes it bind the corresponding AF_INET6 port. I think that's wrong. But maybe it's just a documentation issue.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49408

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65677] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2014-10-13 16:50 ` [ruby-core:65676] " lucas
@ 2014-10-13 17:10 ` akr
  2014-10-13 17:35 ` [ruby-core:65679] " lucas
  2014-10-14 12:15 ` [ruby-core:65702] " akr
  14 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-10-13 17:10 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Akira Tanaka.


Ruby uses getaddrinfo() to obtain addresses to bind.

```
% ./ruby -rsocket -e 'p Addrinfo.getaddrinfo(nil, 10001, nil, :STREAM, nil, Socket::AI_PASSIVE)'
[#<Addrinfo: 0.0.0.0:10001 TCP>, #<Addrinfo: [::]:10001 TCP>]
```

TCPServer.new returns the first socket succeed to bind.

If net.ipv6.bindv6only=1, the first TCPServer.new returns IPv4 socket and the second returns IPv6 socket.

If net.ipv6.bindv6only=0, first TCPServer.new returns IPv4 socket and second fails because
IPv6 socket for 10001 needs IPv4 10001 but it is already used, I guess.

The biggest problem here is TCPServer.new returns only one socket.
I think TCP server should listen all addresses obtained by getaddrinfo() but it is impossible with TCPServer.new().

So, my suggestion again:
I recommend Socket.tcp_server_sockets.






----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49409

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65679] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2014-10-13 17:10 ` [ruby-core:65677] " akr
@ 2014-10-13 17:35 ` lucas
  2014-10-14 12:15 ` [ruby-core:65702] " akr
  14 siblings, 0 replies; 16+ messages in thread
From: lucas @ 2014-10-13 17:35 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Lucas Nussbaum.


I was not interested in adding IPv6 support to my application, only in binding a port with a fallback mechanism. I worked around the problem with bind('0.0.0.0', 10001).

But I still think that it is wrong that TCPServer.new implements this fallback mechanism. It would be less surprising if it just tried to bind the first address, and fail if unsuccessful. I can't think of a scenario where this is useful.

----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49411

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:65702] [ruby-trunk - Bug #10203] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
       [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2014-10-13 17:35 ` [ruby-core:65679] " lucas
@ 2014-10-14 12:15 ` akr
  14 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-10-14 12:15 UTC (permalink / raw
  To: ruby-core

Issue #10203 has been updated by Akira Tanaka.


I'm not sure that ignoring getaddrinfo()'s non-first entries is a good behavior.


----------------------------------------
Bug #10203: TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname
https://bugs.ruby-lang.org/issues/10203#change-49430

* Author: Lucas Nussbaum
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
after:
irb(main):003:0> TCPServer::new(10001)
=> #<TCPServer:fd 9>
I get irb listening to port 10001 using IPv4, but not IPv6:
tcp        0      0 0.0.0.0:10001           0.0.0.0:* LISTEN      1000       376068      24437/irb

a second creation also works, but only binds the IPv6 address:
irb(main):004:0> TCPServer::new(10001)
=> #<TCPServer:fd 10>
tcp6       0      0 :::10001                :::* LISTEN      1000       376098      24437/irb

=> I would have expected the first creation to bind to both IPv4 and IPv6, not just IPv4, and the second attempt to fail.

Trying once again, the creation fails with a strange exception:
irb(main):007:0> TCPServer::new(10001)
TypeError: no implicit conversion of nil into String
	from (irb):7:in `initialize'
	from (irb):7:in `new'
	from (irb):7
	from /usr/bin/irb:11:in `<main>'


Binding explicitely to 0.0.0.0 avoids this:
irb(main):005:0> TCPServer::new('0.0.0.0', 10002)
=> #<TCPServer:fd 11>
irb(main):006:0> TCPServer::new('0.0.0.0', 10002)
Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 10002
	from (irb):6:in `initialize'
	from (irb):6:in `new'
	from (irb):6
	from /usr/bin/irb:11:in `<main>'



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-10-14 12:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-10203.20140904152043@ruby-lang.org>
2014-09-04 15:20 ` [ruby-core:64769] [ruby-trunk - Bug #10203] [Open] TCPServer.new has strange behaviour when EADDRINUSE without specifying hostname lucas
2014-09-05  7:07 ` [ruby-core:64785] [ruby-trunk - Bug #10203] " naruse
2014-09-05  7:25 ` [ruby-core:64786] " lucas
2014-09-05  9:12 ` [ruby-core:64788] " lucas
2014-10-13  6:59 ` [ruby-core:65646] [ruby-trunk - Bug #10203] [Feedback] " akr
2014-10-13  7:10 ` [ruby-core:65647] [ruby-trunk - Bug #10203] " lucas
2014-10-13  8:32   ` [ruby-core:65657] " Eric Wong
2014-10-13  8:40 ` [ruby-core:65658] " normalperson
2014-10-13  9:01 ` [ruby-core:65660] " akr
2014-10-13 11:37 ` [ruby-core:65667] " lucas
2014-10-13 11:41 ` [ruby-core:65668] " lucas
2014-10-13 12:41 ` [ruby-core:65671] " akr
2014-10-13 16:50 ` [ruby-core:65676] " lucas
2014-10-13 17:10 ` [ruby-core:65677] " akr
2014-10-13 17:35 ` [ruby-core:65679] " lucas
2014-10-14 12:15 ` [ruby-core:65702] " akr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).