Last Modified
2015-06-10 17:34:19 -0700
Requires
  • socket
  • fcntl
  • timeout
  • thread
  • securerandom
  • win32/resolv
  • win32/resolv

Description

resolv library

resolv.rb is a resolver library written in Ruby. Since it is written in Ruby, it is thread-aware. I.e. it can resolv many hostnames concurrently.

It is possible to lookup various resources of DNS using DNS module directly.

example

p Resolv.getaddress("www.ruby-lang.org")
p Resolv.getname("210.251.121.214")

Resolv::DNS.open {|dns|
  p dns.getresources("www.ruby-lang.org", Resolv::DNS::Resource::IN::A).collect {|r| r.address}
  p dns.getresources("ruby-lang.org", Resolv::DNS::Resource::IN::MX).collect {|r| [r.exchange.to_s, r.preference]}
}

Resolv class

class methods

blog comments powered by Disqus