22 #ifndef NDN_CXX_TRANSPORT_DETAIL_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
23 #define NDN_CXX_TRANSPORT_DETAIL_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
33 template<
typename BaseTransport,
typename Protocol>
43 connect(std::string_view host, std::string_view port)
50 auto hostAndPort = std::string(host) +
':' + std::string(port);
55 this->
m_connectTimer.async_wait([
self = this->shared_from_base(), hostAndPort] (
const auto& ec) {
59 self->m_transport.close();
61 "could not connect to NDN forwarder at " + hostAndPort));
64 auto resolver = make_shared<typename Protocol::resolver>(this->
m_socket.get_executor());
65 resolver->async_resolve(host, port,
66 [
self = this->shared_from_base(), hostAndPort, resolver] (
auto&&... args) {
67 self->resolveHandler(hostAndPort, std::forward<decltype(args)>(args)...);
74 const boost::system::error_code& error,
75 const typename Protocol::resolver::results_type& endpoints)
78 if (error == boost::asio::error::operation_aborted)
85 BOOST_ASSERT(!endpoints.empty());
88 this->
m_socket.async_connect(this->
m_endpoint, [
self = this->shared_from_base()] (
const auto& ec) {
89 self->connectHandler(ec);
99 return std::static_pointer_cast<Impl>(this->shared_from_this());
Implementation detail of a Boost.Asio-based stream-oriented transport.
Protocol::socket m_socket
boost::asio::steady_timer m_connectTimer
Protocol::endpoint m_endpoint
BaseTransport & m_transport
Implementation detail of a Boost.Asio-based stream-oriented transport with resolver support.
StreamTransportWithResolverImpl(BaseTransport &transport, boost::asio::io_context &ioCtx)
void connect(std::string_view host, std::string_view port)
void resolveHandler(const std::string &hostAndPort, const boost::system::error_code &error, const typename Protocol::resolver::results_type &endpoints)
Contains implementation details that are not part of the ndn-cxx public API.
::boost::chrono::seconds seconds