11 #ifndef ASIO_DETAIL_RESOLVER_SERVICE_HPP 12 #define ASIO_DETAIL_RESOLVER_SERVICE_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 20 #if !defined(ASIO_WINDOWS_RUNTIME) 22 #include "asio/ip/basic_resolver_query.hpp" 23 #include "asio/ip/basic_resolver_results.hpp" 24 #include "asio/detail/concurrency_hint.hpp" 25 #include "asio/detail/memory.hpp" 26 #include "asio/detail/resolve_endpoint_op.hpp" 27 #include "asio/detail/resolve_query_op.hpp" 28 #include "asio/detail/resolver_service_base.hpp" 30 #include "asio/detail/push_options.hpp" 35 template <
typename Protocol>
43 typedef socket_ops::shared_cancel_token_type implementation_type;
46 typedef typename Protocol::endpoint endpoint_type;
64 this->base_shutdown();
70 this->base_notify_fork(fork_ev);
74 results_type resolve(implementation_type&,
const query_type& qry,
77 asio::detail::addrinfo_type* address_info = 0;
79 socket_ops::getaddrinfo(qry.
host_name().c_str(),
83 return ec ? results_type() : results_type::create(
88 template <
typename Handler,
typename IoExecutor>
89 void async_resolve(implementation_type& impl,
const query_type& qry,
90 Handler& handler,
const IoExecutor& io_ex)
94 typename op::ptr p = { asio::detail::addressof(handler),
95 op::ptr::allocate(handler), 0 };
96 p.p =
new (p.v) op(impl, qry, scheduler_, handler, io_ex);
98 ASIO_HANDLER_CREATION((scheduler_.context(),
99 *p.p,
"resolver", &impl, 0,
"async_resolve"));
101 start_resolve_op(p.p);
106 results_type resolve(implementation_type&,
109 char host_name[NI_MAXHOST];
110 char service_name[NI_MAXSERV];
111 socket_ops::sync_getnameinfo(endpoint.data(), endpoint.size(),
112 host_name, NI_MAXHOST, service_name, NI_MAXSERV,
113 endpoint.protocol().type(), ec);
115 return ec ? results_type() : results_type::create(
116 endpoint, host_name, service_name);
120 template <
typename Handler,
typename IoExecutor>
121 void async_resolve(implementation_type& impl,
const endpoint_type& endpoint,
122 Handler& handler,
const IoExecutor& io_ex)
126 typename op::ptr p = { asio::detail::addressof(handler),
127 op::ptr::allocate(handler), 0 };
128 p.p =
new (p.v) op(impl, endpoint, scheduler_, handler, io_ex);
130 ASIO_HANDLER_CREATION((scheduler_.context(),
131 *p.p,
"resolver", &impl, 0,
"async_resolve"));
133 start_resolve_op(p.p);
141 #include "asio/detail/pop_options.hpp" 143 #endif // !defined(ASIO_WINDOWS_RUNTIME) 145 #endif // ASIO_DETAIL_RESOLVER_SERVICE_HPP
void notify_fork(execution_context::fork_event fork_ev)
Handle notification of a fork-related event to perform any necessary housekeeping.
Definition: resolver_service.hpp:68
const asio::detail::addrinfo_type & hints() const
Get the hints associated with the query.
Definition: basic_resolver_query.hpp:216
Definition: resolve_query_op.hpp:43
Definition: resolve_endpoint_op.hpp:42
Definition: execution_context.hpp:386
Definition: resolver_service.hpp:36
A context for function object execution.
Definition: execution_context.hpp:105
std::string service_name() const
Get the service name associated with the query.
Definition: basic_resolver_query.hpp:228
fork_event
Fork-related event notifications.
Definition: execution_context.hpp:142
Class to represent an error code value.
Definition: error_code.hpp:80
Definition: resolver_service_base.hpp:40
Definition: resolver_service_base.hpp:99
void shutdown()
Destroy all user-defined handler objects owned by the service.
Definition: resolver_service.hpp:62
std::string host_name() const
Get the host name associated with the query.
Definition: basic_resolver_query.hpp:222
execution_context & context()
Get the context object that owns the service.
Definition: execution_context.hpp:100
Definition: any_io_executor.hpp:28