Class | Resolv::DNS::Requester::UnconnectedUDP
In: | resolv.rb
Parent: | Requester

### Methods

new sender

### Classes and Modules

Class Resolv::DNS::Requester::UnconnectedUDP::Sender

### Public Class methods

new()

[Source]

    # File resolv.rb, line 570
            def initialize
              super()
              @sock = UDPSocket.new
              @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
              @id = {}
              @id.default = -1
              @thread = Thread.new {
                DNSThreadGroup.add Thread.current
                loop {
                  reply, from = @sock.recvfrom(UDPSize)
                  msg = begin
                    Message.decode(reply)
                  rescue DecodeError
                    STDERR.print("DNS message decoding error: #{reply.inspect}\n")
                    next
                  end
                  if s = @senders[[[from[3],from[1]],msg.id]]
                    s.recv msg
                  else
                    #STDERR.print("non-handled DNS message: #{msg.inspect} from #{from.inspect}\n")
                  end
                }
              }
            end

### Public Instance methods

sender(msg, data, queue, host, port=Port)

[Source]

    # File resolv.rb, line 595
            def sender(msg, data, queue, host, port=Port)
              service = [host, port]
              id = Thread.exclusive {
                @id[service] = (@id[service] + 1) & 0xffff
              }
              request = msg.encode
              request[0,2] = [id].pack('n')
              return @senders[[service, id]] =
                Sender.new(request, data, @sock, host, port, queue)
            end

[Validate]