# File lib/Dnsruby/DNS.rb, line 165
    def send_query(name, type=Types.A, klass=Classes.IN)
      q = Queue.new
      candidates = @config.generate_candidates(name)
      exception = nil
      candidates.each do |candidate|
        msg = Message.new
        msg.header.rd = 1
        msg.add_question(candidate, type, klass)
        @resolver.send_async(msg, q, q)
        id, ret, exception = q.pop
        if (exception == nil && ret.header.rcode == RCode.NOERROR)
          return ret, ret.question[0].qname
        end
        #        if (ret.kind_of?Message)
        #          exception = ret.header.rcode
        #          if (ret.header.rcode==RCode.NOERROR)
        #            return ret, ret.question[0].qname
        #          end
        #        else
        #          #@TODO@ Keep trying until all the candidates are done
        #          #          raise ret
        #          exception = ret
        #        end
      end
      raise exception
    end