Forum: Ruby resolv-replace issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E813e0a366e5d5ddc302fa57a0fc2fab?d=identicon&s=25 Curtis Spencer (Guest)
on 2006-05-03 19:02
(Received via mailing list)
Hi,

I am trying to get some more parallelism out of a crawler I wrote by
using resolv-replace, but I can't seem to get it to correctly resolve
addresses.  I tryed the following code:

require 'net/http'
require 'open-uri'
require 'resolv-replace'

Thread.abort_on_exception = true
thread = Thread.new do
  begin
    open('http://www.google.com') do |file|
      puts file.read
    end
  rescue
    puts $!
  end
end

thread = Thread.new do
  begin
    Net::HTTP.get("www.google.com", "/")
  rescue
    puts $!
  else
    puts "success"
  end
end

1.upto(50) do
  puts "ping"
  sleep 1
end

This doesn't work unless I comment out the require 'resolv-replace'
line.  If I try it with the resolv-replace, then I get output like this:
ping
ping
ping
ping
Hostname not known: www.google.com
ping
Hostname not known: www.google.com

Any ideas why it can't resolve, yet when I use the non ruby resolver it
works correctly.  My ruby version is:

ruby 1.8.4 (2005-12-24) [i686-darwin8.6.1]

Thanks,
Curtis
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-05-03 19:03
(Received via mailing list)
On May 2, 2006, at 2:20 PM, Curtis Spencer wrote:

> [...]
>
> This doesn't work unless I comment out the require 'resolv-replace'
> line.  If I try it with the resolv-replace, then I get output like
> this:

resolv-replace is working fine for me with your (snipped) code.  Make
sure your resolv.conf and hosts file get picked up correctly by resolv.

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
This topic is locked and can not be replied to.