Socket problem on Windows?

Hello,

I’m new to Ruby. I’ve written a very simple program. It will not run on
Windows XP (at work), but it will run on Mac OS X (at home). I’ve tried
1.6.8 and 1.8.0 preview 2 on Windows XP and 1.6.7 on Mac OS X. Here’s the
code:

require ‘resolv’

class ResolverTest
def run()
dns = Resolv::DNS.new
dns.getresources(“www.apogent.com”,
Resolv::DNS::Resource::IN::A).collect {|r| r.address}
puts("#{r}\n")
end
end

resolver = ResolverTest.new()
resolver.run()

Here’s the error:

C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:559:in connect': The requested address is not valid in its context. - "connect(2)" (Errno::E10049) from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:559:ininitialize’
from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:351:in new' from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:351:inlazy_initialize’
from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:346:in synchronize' from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:346:inlazy_initialize’
from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:413:in each_resource' from C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:408:ingetresources’
from C:\projects\test\ruby\TestProject/ResolverTest.rb:6:in `run’
from C:\projects\test\ruby\TestProject/ResolverTest.rb:12

Please share any ideas that you may have regarding this problem.

Thanks,
Craig

I’m new to Ruby. I’ve written a very simple program. It will not run on
Windows XP (at work), but it will run on Mac OS X (at home). I’ve tried
1.6.8 and 1.8.0 preview 2 on Windows XP and 1.6.7 on Mac OS X. Here’s the
code:

Don’t know, but it breaks on win2k too.

“Craig Demyanovich” demmer12@mac.com wrote in message

Hello,

[snip]

Here’s the code:

require ‘resolv’

class ResolverTest
def run()
dns = Resolv::DNS.new
dns.getresources(“www.apogent.com”,
Resolv::DNS::Resource::IN::A).collect {|r| r.address}
puts(“#{r}\n”)
end
end

resolver = ResolverTest.new()
resolver.run()

Here’s the error:

C:/devtools/ruby/1.6.8/lib/ruby/1.6/resolv.rb:559:in `connect’: The
requested address is not valid in its context. - “connect(2)”
(Errno::E10049)

[snip]

Apparently, there is a patch for “resolv.rb” on win32 which you may need to
apply.
I don’t know if this has been recently discussed on ruby-talk but I found
this old reference on
ruby-dev which is a clue:

···

Subject: [ruby-dev:16289] win32/registry.rb and resolv.rb patch for win32
platform
From: Tietew tietew-ml-ruby-dev@tietew.net
Date: Fri, 8 Mar 2002 20:58:48 +0900)

Searching on ruby-talk for resolv.rb brings back quite a few threads, which
you
may have to trawl through. Of course, there are very knowledgeable Rubyzens
here
who might have a direct answer.

Many thanks to those who responded. I will investigate your ideas when I am
able to resume my exploration of Ruby, which is likely next week some time.

Regards,
Craig

“Shashank Date” sdate@everestkc.net wrote in message

Apparently, there is a patch for “resolv.rb” on win32 which you may
need to apply.

I was able to ugly-hack this file till the error shifted to :

C:/ruby/lib/ruby/1.8/resolv_new.rb:614:in `fcntl’: The fcntl() function
is unimplemented on this machine (NotImplementedError)

and then I gave up.

Hello,

In message “Re: socket problem on Windows?”

···

on Jun.13,2003 12:28:23, sdate@everestkc.net wrote:

Apparently, there is a patch for “resolv.rb” on win32 which you may need to
apply.
I don’t know if this has been recently discussed on ruby-talk but I found
this old reference on
ruby-dev which is a clue:

Subject: [ruby-dev:16289] win32/registry.rb and resolv.rb patch for win32
platform
From: Tietew tietew-ml-ruby-dev@tietew.net
Date: Fri, 8 Mar 2002 20:58:48 +0900)

Here is most recently version of this patch.
http://www.moonwolf.com/~arcml/cgi-bin/arcml/arcml.cgi?rm=view;list_id=1;ml_count=548

We are working to import the patch to 1.8 release.
But there are some problems, so I doubt we cannot include it
in the release.

Regards,

U.Nakamura usa@osb.att.ne.jp

“Craig Demyanovich” demmer12@mac.com wrote in message

I will investigate your ideas when I am
able to resume my exploration of Ruby, which is likely next week some
time.

Make sure that you download the latest patch (see U.Nakamura’s post for URL)
I tried it on my WinXP Pro and it worked.

Best of luck !
– shanko