# Resolv-replace issue

**URL:** <https://www.ruby-forum.com/t/resolv-replace-issue/59420>\
**Category:** Ruby\
**Created:** [May 3, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/resolv-replace-issue/59420 "2006-05-03T19:02:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [May 3, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/resolv-replace-issue/59420/1 "2006-05-03T19:02:49Z")

</div>

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](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](http://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](http://www.google.com)  
ping  
Hostname not known: [www.google.com](http://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

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [May 3, 2006, 7:03pm UTC](https://www.ruby-forum.com/t/resolv-replace-issue/59420/2 "2006-05-03T19:03:49Z")

</div>

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 H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
