Problem with sockets in Ruby 1.8.5

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.

Hi,

In message “Re: Problem with sockets in Ruby 1.8.5”
on Thu, 5 Oct 2006 17:17:18 +0900, “Dido S.”
[email protected] 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.

On 10/6/06, Yukihiro M. [email protected] 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 © 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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs