# Problem with sockets in Ruby 1.8.5

**URL:** <https://www.ruby-forum.com/t/problem-with-sockets-in-ruby-1-8-5/71097>\
**Category:** Ruby\
**Created:** [October 5, 2006, 10:18am UTC](https://www.ruby-forum.com/t/problem-with-sockets-in-ruby-1-8-5/71097 "2006-10-05T10:18:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dido\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@Dido\_S](https://www.ruby-forum.com/u/Dido_S)\
**Post date:** [October 5, 2006, 10:18am UTC](https://www.ruby-forum.com/t/problem-with-sockets-in-ruby-1-8-5/71097/1 "2006-10-05T10:18:12Z")

</div>

I’ve just updated to Ruby 1.8.5 and tried using Webrick for a little  
application. Funny thing was if I didn’t specify a bind address,  
Webrick crashed with a SocketError. I isolated the code that causes  
this problem, and it turns out to be a Socket::getaddrinfo call:

$ ruby -ve ‘require “socket”; Socket::getaddrinfo(nil, 12345,  
Socket::AF\_UNSPEC, Socket::SOCK\_STREAM, 0, Socket::AI\_PASSIVE)’  
ruby 1.8.5 (2006-08-25) [i686-linux]  
-e:1:in `getaddrinfo’: getnameinfo: ai\_family not supported  
(SocketError)  
from -e:1

No such problems on Ruby 1.9 (2006-09-29) or Ruby 1.8.2 (2004-12-25)  
or Ruby 1.8.4 (2005-12-24). I’m on Gentoo Linux. Apparently the bind  
address must be set to some address (0.0.0.0 works just fine), but it  
cannot be nil. Since it appears that lots of existing code using the  
Socket library doesn’t set an explicit bind address as required here,  
it seems that updating to 1.8.5 might cause lots of breakage.

---

<div class="post-metadata">

**Author:** ![Dido\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@Dido\_S](https://www.ruby-forum.com/u/Dido_S)\
**Post date:** [October 6, 2006, 9:12am UTC](https://www.ruby-forum.com/t/problem-with-sockets-in-ruby-1-8-5/71097/2 "2006-10-06T09:12:46Z")

</div>

Hi,

In message “Re: Problem with sockets in Ruby 1.8.5”  
on Thu, 5 Oct 2006 17:17:18 +0900, “Dido S.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|this problem, and it turns out to be a Socket::getaddrinfo call:  
|  
|$ ruby -ve ‘require “socket”; Socket::getaddrinfo(nil, 12345,  
|Socket::AF\_UNSPEC, Socket::SOCK\_STREAM, 0, Socket::AI\_PASSIVE)’  
|ruby 1.8.5 (2006-08-25) [i686-linux]  
|-e:1:in `getaddrinfo’: getnameinfo: ai\_family not supported (SocketError)  
| from -e:1

My 1.8.5 does not raise any error on Debian sid. That might be caused  
by configure options. Can you show us your configure options?

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![Dido\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@Dido\_S](https://www.ruby-forum.com/u/Dido_S)\
**Post date:** [October 6, 2006, 11:13pm UTC](https://www.ruby-forum.com/t/problem-with-sockets-in-ruby-1-8-5/71097/3 "2006-10-06T23:13:23Z")

</div>

On 10/6/06, Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My 1.8.5 does not raise any error on Debian sid. That might be caused  
> by configure options. Can you show us your configure options?

Strange. Well, I’m just using the standard ebuild with threading and  
cjk enabled, and so that translates to the following configure  
options:

configure --program-suffix=18 --enable-shared --enable-pthread   
–with-sitedir=/usr/lib/ruby/site\_ruby

Since I have the cjk use option enabled Gentoo also patches my Ruby  
with Oniguruma. I built it using GCC 4.1.1 (gentoo-r1), and glibc  
2.4:

GNU C Library development release version 2.4, by Roland McGrath et al.  
Copyright (C) 2006 Free Software Foundation, Inc.  
This is free software; see the source for copying conditions.  
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A  
PARTICULAR PURPOSE.  
Compiled by GNU CC version 4.1.1 (Gentoo 4.1.1-r1).  
Compiled on a Linux 2.6.17 system on 2006-09-14.  
Available extensions:  
The C stubs add-on version 2.1.2.  
crypt add-on version 2.1 by Michael Glad and others  
GNU Libidn by Simon Josefsson  
GNU libio by Per Bothner  
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk  
Native POSIX Threads Library by Ulrich Drepper et al  
Support for some architectures added on, not maintained in glibc  
core.  
BIND-8.2.3-T5B  
Thread-local storage support included.  
For bug reporting instructions, please see:  
[http://www.gnu.org/software/libc/bugs.html](http://www.gnu.org/software/libc/bugs.html).

I’m running Ruby 1.9.0 on the same system built with the same compiler  
and don’t experience the same problem with it.

As a bit of an experiment I tried to build with gcc 3.4.6 (Gentoo-r1),  
and it still fails to work.
