vendor/bundle/ruby/2.7.0/gems/dnsruby-1.61.5/lib/dnsruby/resolver.rb
#  Asynchronously send a Message to the server. The send can be done using just
#  Dnsruby. Support for EventMachine has been deprecated.
#
#  == Dnsruby pure Ruby event loop :
#
#  A client_queue is supplied by the client,
#  along with an optional client_query_id to identify the response. The client_query_id
#  is generated, if not supplied, and returned to the client.
#  When the response is known,
#  a tuple of (query_id, response_message, exception) will be added to the client_queue.
#
#  The query is sent synchronously in the caller's thread. The select thread is then used to
#  listen for and process the response (up to pushing it to the client_queue). The client thread
#  is then used to retrieve the response and deal with it.
#
#  Takes :
#
#  * msg - the message to send
#  * client_queue - a Queue to push the response to, when it arrives
#  * client_query_id - an optional ID to identify the query to the client
#  * use_tcp - whether to use only TCP (defaults to SingleResolver.use_tcp)
#
#  Returns :
#
#  * client_query_id - to identify the query response to the client. This ID is
#  generated if it is not passed in by the client
#
#  === Example invocations :
#
#     id = res.send_async(msg, queue)
#     NOT SUPPORTED : id = res.send_async(msg, queue, use_tcp)
#     id = res.send_async(msg, queue, id)
#     id = res.send_async(msg, queue, id, use_tcp)
#
#  === Example code :
#
#    require 'dnsruby'
#    res = Dnsruby::Resolver.newsend
#    query_id = 10 # can be any object you like
#    query_queue = Queue.new
#    res.send_async(Message.new('example.com', Types.MX),  query_queue, query_id)
#    query_id_2 = res.send_async(Message.new('example.com', Types.A), query_queue)
#    # ...do a load of other stuff here...
#    2.times do
#      response_id, response, exception = query_queue.pop
#      # You can check the ID to see which query has been answered
#      if exception == nil
#          # deal with good response
#      else
#          # deal with problem
#      end
#    end
#
Asynchronously send a Message to the server. The send can be done using just
Dnsruby. Support for EventMachine has been deprecated.

Dnsruby pure Ruby event loop .

A client_queue is supplied by the client,
along with an optional client_query_id to identify the response. The client_query_id
is generated, if not supplied, and returned to the client.
When the response is known,
a tuple of (query_id, response_message, exception) will be added to the client_queue.

The query is sent synchronously in the caller's thread. The select thread is then used to
listen for and process the response (up to pushing it to the client_queue). The client thread
is then used to retrieve the response and deal with it.

Takes .

the message to send
client_queue - a Queue to push the response to, when it arrives
client_query_id - an optional ID to identify the query to the client
use_tcp - whether to use only TCP (defaults to SingleResolver.use_tcp)

Returns .

to identify the query response to the client. This ID is
generated if it is not passed in by the client

Example invocations .



Example code .


Asynchronously send a Message to the server . The send can be done using just Dnsruby . Support for EventMachine has been deprecated . Dnsruby pure Ruby event loop . A client_queue is supplied by the client along with an optional client_query_id to identify the response . The client_query_id is generated if not supplied and returned to the client . When the response is known a tuple of ( query_id response_message exception ) will be added to the client_queue . The query is sent synchronously in the caller ' s thread . The select thread is then used to listen for and process the response ( up to pushing it to the client_queue ) . The client thread is then used to retrieve the response and deal with it . Takes . the message to send client_queue - a Queue to push the response to when it arrives client_query_id - an optional ID to identify the query to the client use_tcp - whether to use only TCP ( defaults to SingleResolver . use_tcp ) Returns . to identify the query response to the client . This ID is generated if it is not passed in by the client Example invocations . Example code .
def send_async(msg, client_queue, client_query_id = nil)
      unless @configured
        add_config_nameservers
      end
      unless @resolver_ruby 
        @resolver_ruby = ResolverRuby.new(self)
      end
      client_query_id = @resolver_ruby.send_async(msg, client_queue, client_query_id)
      if @single_resolvers.length == 0
        Thread.start {
          sleep(@query_timeout == 0 ? 1 : @query_timeout)
          client_queue.push([client_query_id, nil, ResolvTimeout.new('Query timed out - no nameservers configured')])
        }
      end
      client_query_id
    end
def send_async ( msg , client_queue , client_query_id = nil ) unless @configured add_config_nameservers end unless @resolver_ruby @resolver_ruby = ResolverRuby . new ( self ) end client_query_id = @resolver_ruby . send_async ( msg , client_queue , client_query_id ) if @single_resolvers . length == 0 Thread . start { sleep ( @query_timeout == 0 ? 1 : @query_timeout ) client_queue . push ( [ client_query_id , nil , ResolvTimeout . new ( 'Query timed out - no nameservers configured' ) ] ) } end client_query_id end
Asynchronously send a Message to the server.
Asynchronously send a Message to the server .
#       @single_res_mutex.synchronize { # @TODO@ Synchronize this? #       }
msg
<not_specific>
client_queue
<not_specific>
client_query_id
<not_specific>