I'm trying the following, but the receive_data is never called, any
idea why?
require "net/dns"
require 'eventmachine'
require 'pp'
class DNSClient < EM::Connection
def initialize(domain,ns)
@domain = domain
@ns = ns
end
def post_init
packet = Net::DNS::Packet.new(@domain)
send_datagram packet, @ns, 53
end
def receive_data data
puts "never gets here"
p = Net::DNS::Packet::parse(data)
end
end
EM.run {
# 216.239.32.10 is google's nameserver. dig @
216.239.32.10 www.google.com
works.
EM.open_datagram_socket "0.0.0.0", 0, DNSClient, "
www.google.com.",
"216.239.32.10"
}