Class: Gem::Resolv::DNS::Requester
Do not use. This class is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Exceptions:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/rubygems/vendor/resolv/lib/resolv.rb |
Class Method Summary
- .new ⇒ Requester constructor
Instance Method Summary
Constructor Details
.new ⇒ Requester
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 658
def initialize @senders = {} @socks = nil end
Instance Method Details
#close
[ GitHub ]# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 714
def close socks = @socks @socks = nil socks&.each(&:close) end
#request(sender, tout)
[ GitHub ]# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 663
def request(sender, tout) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) timelimit = start + tout begin sender.send rescue Errno::EHOSTUNREACH, # multi-homed IPv6 may generate this Errno::ENETUNREACH raise ResolvTimeout end while true before_select = Process.clock_gettime(Process::CLOCK_MONOTONIC) timeout = timelimit - before_select if timeout <= 0 raise ResolvTimeout end if @socks.size == 1 select_result = @socks[0].wait_readable(timeout) ? [ @socks ] : nil else select_result = IO.select(@socks, nil, nil, timeout) end if !select_result after_select = Process.clock_gettime(Process::CLOCK_MONOTONIC) next if after_select < timelimit raise ResolvTimeout end begin reply, from = recv_reply(select_result[0]) rescue Errno::ECONNREFUSED, # GNU/Linux, FreeBSD Errno::ECONNRESET # Windows # No name server running on the server? # Don't wait anymore. raise ResolvTimeout end begin msg = Message.decode(reply) rescue DecodeError next # broken DNS message ignored end if sender == sender_for(from, msg) break else # unexpected DNS message ignored end end return msg, sender.data end
#sender_for(addr, msg)
[ GitHub ]# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 710
def sender_for(addr, msg) @senders[[addr,msg.id]] end