Socket.gethosbyname AgrumentError

Hi.

I have upgraded and one of my scripts now dies with ArgumentError while
calling Socket.gethostbyname - see bellow.
Can someone explain to me why this is happening? Can it be caused by an
interference with IPv6?

Thanks,

Dalibor Sramek

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

dali@epot:~$ ruby -v
ruby 1.8.1 (2003-12-25) [i386-freebsd5.2]
dali@epot:~$ irb
irb(main):001:0> require ‘socket’
=> true
irb(main):002:0> Socket.gethostbyname(‘146.102.77.77’)
ArgumentError: NULL pointer given
from (irb):2:in aethostbyname’
from (irb):2
irb(main):003:0>

dali@epot:~$ nslookup 146.102.77.77
Server: ns1.casablanca.cz
Address: 217.11.224.1

Name: sM05h01.vse.cz
Address: 146.102.77.77

···


Dalibor Sramek http://www.insula.cz/dali | In the eyes of cats,
dalibor.sramek@insula.cz | all things belong to cats.

Seems to work on Debian Sarge Linux.

bash-2.05b$ ruby -v
ruby 1.8.1 (2003-11-11) [i386-linux]

irb(main):001:0> require ‘socket’
=> true

irb(main):003:0> Socket.gethostbyname(‘146.102.77.77’)
=> [“sM05h01.vse.cz”, , 2,
“\002\000\000\000\222fMM\000\000\000\000\000\000\00
0\000”]

You could always try using a redirect:

irb(main):005:0> myip = IO.readlines(“|/usr/bin/host 146.102.77.77”)
=> [“Name: sM05h01.vse.cz\n”, “Address: 146.102.77.77\n”, “\n”]
irb(main):006:0> print “debug: myip is " + myip[0].chomp!,”\n"
debug: myip is Name: sM05h01.vse.cz
=> nil

···

On 23/01/04 05:44 +0900, Dalibor Sramek wrote:

Hi.

I have upgraded and one of my scripts now dies with ArgumentError while
calling Socket.gethostbyname - see bellow.
Can someone explain to me why this is happening? Can it be caused by an
interference with IPv6?

Thanks,

Dalibor Sramek

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

dali@epot:~$ ruby -v
ruby 1.8.1 (2003-12-25) [i386-freebsd5.2]
dali@epot:~$ irb
irb(main):001:0> require ‘socket’
=> true
irb(main):002:0> Socket.gethostbyname(‘146.102.77.77’)
ArgumentError: NULL pointer given
from (irb):2:in aethostbyname’
from (irb):2
irb(main):003:0>

dali@epot:~$ nslookup 146.102.77.77
Server: ns1.casablanca.cz
Address: 217.11.224.1

Name: sM05h01.vse.cz
Address: 146.102.77.77


Dalibor Sramek insula.cz | In the eyes of cats,
dalibor.sramek@insula.cz | all things belong to cats.

Ted Knab
Chester, MD 21619

35570707f6274702478656021626f6c6964796f6e602f66602478656
02e6164796f6e60237471647560216e6460276c6f62616c60257e696
4797e2a0

I have upgraded and one of my scripts now dies with ArgumentError while
calling Socket.gethostbyname - see bellow.
Can someone explain to me why this is happening? Can it be caused by an
interference with IPv6?

Dalibor,

It’s BSD-specific. I had the same problem and reported it as:
http://www.ruby-lang.org/cgi-bin/ruby-bugs/incoming?id=1243

-neil

···

On Fri, Jan 23, 2004 at 05:44:56AM +0900, Dalibor Sramek wrote:

Thanks,

Dalibor Sramek

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

dali@epot:~$ ruby -v
ruby 1.8.1 (2003-12-25) [i386-freebsd5.2]
dali@epot:~$ irb
irb(main):001:0> require ‘socket’
=> true
irb(main):002:0> Socket.gethostbyname(‘146.102.77.77’)
ArgumentError: NULL pointer given
from (irb):2:in aethostbyname’
from (irb):2
irb(main):003:0>

dali@epot:~$ nslookup 146.102.77.77
Server: ns1.casablanca.cz
Address: 217.11.224.1

Name: sM05h01.vse.cz
Address: 146.102.77.77


Dalibor Sramek insula.cz | In the eyes of cats,
dalibor.sramek@insula.cz | all things belong to cats.