Method: DNS::Client#query

Defined in:
lib/faildns/client.rb

#query(message, timeout = 10) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/faildns/client.rb', line 94

def query (message, timeout=10)
  result = []
  socket = UDPSocket.new

  @servers.each {|server|
    socket.connect(server.to_s, 53)

    socket.print message.pack

    if (tmp = Timeout.timeout(timeout) { socket.recvfrom(512) } rescue nil)
      DNS.debug tmp, { :level => 9 }

      result.push Message.parse(tmp[0])
    end
  }

  return result
end