Module: RubyDNS::Resolver::Request::UDPRequestHandler
- Defined in:
- lib/rubydns/resolver.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.open(host, port, request) ⇒ Object
195 196 197 198 |
# File 'lib/rubydns/resolver.rb', line 195 def self.open(host, port, request) # Open a datagram socket... a random socket chosen by the OS by specifying 0 for the port: EventMachine::open_datagram_socket('', 0, self, request, host, port) end |
Instance Method Details
#initialize(request, host, port) ⇒ Object
200 201 202 203 204 |
# File 'lib/rubydns/resolver.rb', line 200 def initialize(request, host, port) @request = request @host = host @port = port end |
#post_init ⇒ Object
206 207 208 209 |
# File 'lib/rubydns/resolver.rb', line 206 def post_init # Sending question to remote DNS server... send_datagram(@request.packet, @host, @port) end |
#receive_data(data) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/rubydns/resolver.rb', line 211 def receive_data(data) # local_port, local_ip = Socket.unpack_sockaddr_in(get_sockname) # puts "Socket name: #{local_ip}:#{local_port}" # Receiving response from remote DNS server... = RubyDNS::(data) # The message id must match, and it can't be truncated: @request.process_response!() rescue Resolv::DNS::DecodeError => error @request.process_response!(error) end |