Method: Resolv::DNS::Requester::ConnectedUDP#lazy_initialize

Defined in:
lib/resolv.rb

#lazy_initializeObject



836
837
838
839
840
841
842
843
844
845
846
847
848
# File 'lib/resolv.rb', line 836

def lazy_initialize
  @mutex.synchronize {
    next if @initialized
    @initialized = true
    is_ipv6 = @host.index(':')
    sock = UDPSocket.new(is_ipv6 ? Socket::AF_INET6 : Socket::AF_INET)
    @socks = [sock]
    sock.do_not_reverse_lookup = true
    DNS.bind_random_port(sock, is_ipv6 ? "::" : "0.0.0.0")
    sock.connect(@host, @port)
  }
  self
end