예제 #1
0
  void
  onResolveSuccess(const boost::system::error_code& error,
                   BoostResolver::iterator remoteEndpoint,
                   const shared_ptr<Resolver>& self)
  {
    m_scheduler.cancelEvent(m_resolveTimeout);

    if (error)
      {
        if (error == boost::system::errc::operation_canceled)
          {
            return;
          }

        return m_onError("Remote endpoint hostname or port cannot be resolved: " +
                         error.category().message(error.value()));
      }

    BoostResolver::iterator end;
    for (; remoteEndpoint != end; ++remoteEndpoint)
      {
        IpAddress address(EndPoint(*remoteEndpoint).address());

        if (m_addressSelector(address))
          {
            return m_onSuccess(address);
          }
      }

    m_onError("No endpoint matching the specified address selector found");
  }
예제 #2
0
파일: resolver.hpp 프로젝트: PhilipsIII/NFD
  void
  onResolveSuccess(const boost::system::error_code& error,
                   typename resolver::iterator remoteEndpoint,
                   const shared_ptr<Resolver>& self)
  {
    scheduler::cancel(m_resolveTimeout);

    if (error)
      {
        if (error == boost::system::errc::operation_canceled)
          return;

        return m_onError("Remote endpoint hostname or port cannot be resolved: " +
                         error.category().message(error.value()));
      }

    typename resolver::iterator end;
    for (; remoteEndpoint != end; ++remoteEndpoint)
      {
        if (m_addressSelector(typename Protocol::endpoint(*remoteEndpoint).address()))
          return m_onSuccess(*remoteEndpoint);
      }

    m_onError("No endpoint matching the specified address selector found");
  }
예제 #3
0
    void
    onResolveResult(const boost::system::error_code& error,
                    iterator it, const shared_ptr<Resolver>& self)
    {
        m_scheduler.cancelEvent(m_resolveTimeout);
        // ensure the Resolver isn't destructed while callbacks are still pending, see #2653
        m_resolver.get_io_service().post(bind([] (const shared_ptr<Resolver>&) {}, self));

        if (error) {
            if (error == boost::asio::error::operation_aborted)
                return;

            if (m_onError)
                m_onError("Hostname cannot be resolved: " + error.message());

            return;
        }

        it = selectAddress(it);

        if (it != iterator() && m_onSuccess) {
            m_onSuccess(it->endpoint().address());
        }
        else if (m_onError) {
            m_onError("No endpoints match the specified address selector");
        }
    }