Forum: Ruby bug on resolv.rb? or I'm just a newbe?

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.
4d0f92e3e5bedaeb0b68742f608bdfe8?d=identicon&s=25 Rodrigo Urubatan (urubatan)
on 2007-07-28 19:20
I can't get the point in this problem ...
this code works fine ...
require 'resolv'
r = Resolv::DNS.new
puts r.getaddress("www.google.com")
r.each_resource("urubatan.com.br", Resolv::DNS::Resource::IN::A) { |mx|
    puts mx
}

but if I change to this
require 'resolv'
r = Resolv::DNS.new
puts r.getaddress("www.google.com")
r.each_resource("urubatan.com.br", Resolv::DNS::Resource::CNAME) { |mx|
    puts mx
}

ot this (that is what I want to do)
require 'resolv'
r = Resolv::DNS.new
puts r.getaddress("www.google.com")
r.each_resource("urubatan.com.br", Resolv::DNS::Resource::MX) { |mx|
    puts mx
}


I get this error:
/usr/lib/ruby/1.8/resolv.rb:1171:in `pack': can't convert nil into
Integer (TypeError)
        from /usr/lib/ruby/1.8/resolv.rb:1171:in `put_pack'
        from /usr/lib/ruby/1.8/resolv.rb:1142:in `encode'
        from /usr/lib/ruby/1.8/resolv.rb:1139:in `each'
        from /usr/lib/ruby/1.8/resolv.rb:1139:in `encode'
        from /usr/lib/ruby/1.8/resolv.rb:1159:in `initialize'
        from /usr/lib/ruby/1.8/resolv.rb:1125:in `new'
        from /usr/lib/ruby/1.8/resolv.rb:1125:in `encode'
        from /usr/lib/ruby/1.8/resolv.rb:652:in `sender'
         ... 6 levels...
        from /usr/lib/ruby/1.8/resolv.rb:868:in `each'
        from /usr/lib/ruby/1.8/resolv.rb:868:in `resolv'
        from /usr/lib/ruby/1.8/resolv.rb:470:in `each_resource'
        from teste.rb:4

I think it is a bug in the ruby base library.
I'm using ruby 1.8, and I have tried this in tree different machines ...

Can some one help me with this please?

Thanks.
4d0f92e3e5bedaeb0b68742f608bdfe8?d=identicon&s=25 Rodrigo Urubatan (urubatan)
on 2007-07-28 21:29
It seems that is a bug in the resolv.rb ...
I found a workaround with the Net::DNS gem ...
and posted the solution in my blog (but this one is in portuguese)
if there is anyone with the same problem, please take a look at here:
http://www.urubatan.com.br/2007/07/28/dicas-rapida...
This topic is locked and can not be replied to.