basic_resolver.hpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. //
  2. // ip/basic_resolver.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_IP_BASIC_RESOLVER_HPP
  11. #define BOOST_ASIO_IP_BASIC_RESOLVER_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <string>
  17. #include <boost/asio/any_io_executor.hpp>
  18. #include <boost/asio/async_result.hpp>
  19. #include <boost/asio/detail/handler_type_requirements.hpp>
  20. #include <boost/asio/detail/io_object_impl.hpp>
  21. #include <boost/asio/detail/non_const_lvalue.hpp>
  22. #include <boost/asio/detail/string_view.hpp>
  23. #include <boost/asio/detail/throw_error.hpp>
  24. #include <boost/asio/error.hpp>
  25. #include <boost/asio/execution_context.hpp>
  26. #include <boost/asio/ip/basic_resolver_iterator.hpp>
  27. #include <boost/asio/ip/basic_resolver_query.hpp>
  28. #include <boost/asio/ip/basic_resolver_results.hpp>
  29. #include <boost/asio/ip/resolver_base.hpp>
  30. #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
  31. # include <boost/asio/detail/winrt_resolver_service.hpp>
  32. #else
  33. # include <boost/asio/detail/resolver_service.hpp>
  34. #endif
  35. #if defined(BOOST_ASIO_HAS_MOVE)
  36. # include <utility>
  37. #endif // defined(BOOST_ASIO_HAS_MOVE)
  38. #include <boost/asio/detail/push_options.hpp>
  39. namespace boost {
  40. namespace asio {
  41. namespace ip {
  42. #if !defined(BOOST_ASIO_IP_BASIC_RESOLVER_FWD_DECL)
  43. #define BOOST_ASIO_IP_BASIC_RESOLVER_FWD_DECL
  44. // Forward declaration with defaulted arguments.
  45. template <typename InternetProtocol, typename Executor = any_io_executor>
  46. class basic_resolver;
  47. #endif // !defined(BOOST_ASIO_IP_BASIC_RESOLVER_FWD_DECL)
  48. /// Provides endpoint resolution functionality.
  49. /**
  50. * The basic_resolver class template provides the ability to resolve a query
  51. * to a list of endpoints.
  52. *
  53. * @par Thread Safety
  54. * @e Distinct @e objects: Safe.@n
  55. * @e Shared @e objects: Unsafe.
  56. */
  57. template <typename InternetProtocol, typename Executor>
  58. class basic_resolver
  59. : public resolver_base
  60. {
  61. public:
  62. /// The type of the executor associated with the object.
  63. typedef Executor executor_type;
  64. /// Rebinds the resolver type to another executor.
  65. template <typename Executor1>
  66. struct rebind_executor
  67. {
  68. /// The resolver type when rebound to the specified executor.
  69. typedef basic_resolver<InternetProtocol, Executor1> other;
  70. };
  71. /// The protocol type.
  72. typedef InternetProtocol protocol_type;
  73. /// The endpoint type.
  74. typedef typename InternetProtocol::endpoint endpoint_type;
  75. #if !defined(BOOST_ASIO_NO_DEPRECATED)
  76. /// (Deprecated.) The query type.
  77. typedef basic_resolver_query<InternetProtocol> query;
  78. /// (Deprecated.) The iterator type.
  79. typedef basic_resolver_iterator<InternetProtocol> iterator;
  80. #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
  81. /// The results type.
  82. typedef basic_resolver_results<InternetProtocol> results_type;
  83. /// Construct with executor.
  84. /**
  85. * This constructor creates a basic_resolver.
  86. *
  87. * @param ex The I/O executor that the resolver will use, by default, to
  88. * dispatch handlers for any asynchronous operations performed on the
  89. * resolver.
  90. */
  91. explicit basic_resolver(const executor_type& ex)
  92. : impl_(0, ex)
  93. {
  94. }
  95. /// Construct with execution context.
  96. /**
  97. * This constructor creates a basic_resolver.
  98. *
  99. * @param context An execution context which provides the I/O executor that
  100. * the resolver will use, by default, to dispatch handlers for any
  101. * asynchronous operations performed on the resolver.
  102. */
  103. template <typename ExecutionContext>
  104. explicit basic_resolver(ExecutionContext& context,
  105. typename constraint<
  106. is_convertible<ExecutionContext&, execution_context&>::value
  107. >::type = 0)
  108. : impl_(0, 0, context)
  109. {
  110. }
  111. #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  112. /// Move-construct a basic_resolver from another.
  113. /**
  114. * This constructor moves a resolver from one object to another.
  115. *
  116. * @param other The other basic_resolver object from which the move will
  117. * occur.
  118. *
  119. * @note Following the move, the moved-from object is in the same state as if
  120. * constructed using the @c basic_resolver(const executor_type&) constructor.
  121. */
  122. basic_resolver(basic_resolver&& other)
  123. : impl_(std::move(other.impl_))
  124. {
  125. }
  126. // All resolvers have access to each other's implementations.
  127. template <typename InternetProtocol1, typename Executor1>
  128. friend class basic_resolver;
  129. /// Move-construct a basic_resolver from another.
  130. /**
  131. * This constructor moves a resolver from one object to another.
  132. *
  133. * @param other The other basic_resolver object from which the move will
  134. * occur.
  135. *
  136. * @note Following the move, the moved-from object is in the same state as if
  137. * constructed using the @c basic_resolver(const executor_type&) constructor.
  138. */
  139. template <typename Executor1>
  140. basic_resolver(basic_resolver<InternetProtocol, Executor1>&& other,
  141. typename constraint<
  142. is_convertible<Executor1, Executor>::value
  143. >::type = 0)
  144. : impl_(std::move(other.impl_))
  145. {
  146. }
  147. /// Move-assign a basic_resolver from another.
  148. /**
  149. * This assignment operator moves a resolver from one object to another.
  150. * Cancels any outstanding asynchronous operations associated with the target
  151. * object.
  152. *
  153. * @param other The other basic_resolver object from which the move will
  154. * occur.
  155. *
  156. * @note Following the move, the moved-from object is in the same state as if
  157. * constructed using the @c basic_resolver(const executor_type&) constructor.
  158. */
  159. basic_resolver& operator=(basic_resolver&& other)
  160. {
  161. impl_ = std::move(other.impl_);
  162. return *this;
  163. }
  164. /// Move-assign a basic_resolver from another.
  165. /**
  166. * This assignment operator moves a resolver from one object to another.
  167. * Cancels any outstanding asynchronous operations associated with the target
  168. * object.
  169. *
  170. * @param other The other basic_resolver object from which the move will
  171. * occur.
  172. *
  173. * @note Following the move, the moved-from object is in the same state as if
  174. * constructed using the @c basic_resolver(const executor_type&) constructor.
  175. */
  176. template <typename Executor1>
  177. typename constraint<
  178. is_convertible<Executor1, Executor>::value,
  179. basic_resolver&
  180. >::type operator=(basic_resolver<InternetProtocol, Executor1>&& other)
  181. {
  182. basic_resolver tmp(std::move(other));
  183. impl_ = std::move(tmp.impl_);
  184. return *this;
  185. }
  186. #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  187. /// Destroys the resolver.
  188. /**
  189. * This function destroys the resolver, cancelling any outstanding
  190. * asynchronous wait operations associated with the resolver as if by calling
  191. * @c cancel.
  192. */
  193. ~basic_resolver()
  194. {
  195. }
  196. /// Get the executor associated with the object.
  197. executor_type get_executor() BOOST_ASIO_NOEXCEPT
  198. {
  199. return impl_.get_executor();
  200. }
  201. /// Cancel any asynchronous operations that are waiting on the resolver.
  202. /**
  203. * This function forces the completion of any pending asynchronous
  204. * operations on the host resolver. The handler for each cancelled operation
  205. * will be invoked with the boost::asio::error::operation_aborted error code.
  206. */
  207. void cancel()
  208. {
  209. return impl_.get_service().cancel(impl_.get_implementation());
  210. }
  211. #if !defined(BOOST_ASIO_NO_DEPRECATED)
  212. /// (Deprecated: Use overload with separate host and service parameters.)
  213. /// Perform forward resolution of a query to a list of entries.
  214. /**
  215. * This function is used to resolve a query into a list of endpoint entries.
  216. *
  217. * @param q A query object that determines what endpoints will be returned.
  218. *
  219. * @returns A range object representing the list of endpoint entries. A
  220. * successful call to this function is guaranteed to return a non-empty
  221. * range.
  222. *
  223. * @throws boost::system::system_error Thrown on failure.
  224. */
  225. results_type resolve(const query& q)
  226. {
  227. boost::system::error_code ec;
  228. results_type r = impl_.get_service().resolve(
  229. impl_.get_implementation(), q, ec);
  230. boost::asio::detail::throw_error(ec, "resolve");
  231. return r;
  232. }
  233. /// (Deprecated: Use overload with separate host and service parameters.)
  234. /// Perform forward resolution of a query to a list of entries.
  235. /**
  236. * This function is used to resolve a query into a list of endpoint entries.
  237. *
  238. * @param q A query object that determines what endpoints will be returned.
  239. *
  240. * @param ec Set to indicate what error occurred, if any.
  241. *
  242. * @returns A range object representing the list of endpoint entries. An
  243. * empty range is returned if an error occurs. A successful call to this
  244. * function is guaranteed to return a non-empty range.
  245. */
  246. results_type resolve(const query& q, boost::system::error_code& ec)
  247. {
  248. return impl_.get_service().resolve(impl_.get_implementation(), q, ec);
  249. }
  250. #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
  251. /// Perform forward resolution of a query to a list of entries.
  252. /**
  253. * This function is used to resolve host and service names into a list of
  254. * endpoint entries.
  255. *
  256. * @param host A string identifying a location. May be a descriptive name or
  257. * a numeric address string. If an empty string and the passive flag has been
  258. * specified, the resolved endpoints are suitable for local service binding.
  259. * If an empty string and passive is not specified, the resolved endpoints
  260. * will use the loopback address.
  261. *
  262. * @param service A string identifying the requested service. This may be a
  263. * descriptive name or a numeric string corresponding to a port number. May
  264. * be an empty string, in which case all resolved endpoints will have a port
  265. * number of 0.
  266. *
  267. * @returns A range object representing the list of endpoint entries. A
  268. * successful call to this function is guaranteed to return a non-empty
  269. * range.
  270. *
  271. * @throws boost::system::system_error Thrown on failure.
  272. *
  273. * @note On POSIX systems, host names may be locally defined in the file
  274. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  275. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  276. * resolution is performed using DNS. Operating systems may use additional
  277. * locations when resolving host names (such as NETBIOS names on Windows).
  278. *
  279. * On POSIX systems, service names are typically defined in the file
  280. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  281. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  282. * may use additional locations when resolving service names.
  283. */
  284. results_type resolve(BOOST_ASIO_STRING_VIEW_PARAM host,
  285. BOOST_ASIO_STRING_VIEW_PARAM service)
  286. {
  287. return resolve(host, service, resolver_base::flags());
  288. }
  289. /// Perform forward resolution of a query to a list of entries.
  290. /**
  291. * This function is used to resolve host and service names into a list of
  292. * endpoint entries.
  293. *
  294. * @param host A string identifying a location. May be a descriptive name or
  295. * a numeric address string. If an empty string and the passive flag has been
  296. * specified, the resolved endpoints are suitable for local service binding.
  297. * If an empty string and passive is not specified, the resolved endpoints
  298. * will use the loopback address.
  299. *
  300. * @param service A string identifying the requested service. This may be a
  301. * descriptive name or a numeric string corresponding to a port number. May
  302. * be an empty string, in which case all resolved endpoints will have a port
  303. * number of 0.
  304. *
  305. * @param ec Set to indicate what error occurred, if any.
  306. *
  307. * @returns A range object representing the list of endpoint entries. An
  308. * empty range is returned if an error occurs. A successful call to this
  309. * function is guaranteed to return a non-empty range.
  310. *
  311. * @note On POSIX systems, host names may be locally defined in the file
  312. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  313. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  314. * resolution is performed using DNS. Operating systems may use additional
  315. * locations when resolving host names (such as NETBIOS names on Windows).
  316. *
  317. * On POSIX systems, service names are typically defined in the file
  318. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  319. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  320. * may use additional locations when resolving service names.
  321. */
  322. results_type resolve(BOOST_ASIO_STRING_VIEW_PARAM host,
  323. BOOST_ASIO_STRING_VIEW_PARAM service, boost::system::error_code& ec)
  324. {
  325. return resolve(host, service, resolver_base::flags(), ec);
  326. }
  327. /// Perform forward resolution of a query to a list of entries.
  328. /**
  329. * This function is used to resolve host and service names into a list of
  330. * endpoint entries.
  331. *
  332. * @param host A string identifying a location. May be a descriptive name or
  333. * a numeric address string. If an empty string and the passive flag has been
  334. * specified, the resolved endpoints are suitable for local service binding.
  335. * If an empty string and passive is not specified, the resolved endpoints
  336. * will use the loopback address.
  337. *
  338. * @param service A string identifying the requested service. This may be a
  339. * descriptive name or a numeric string corresponding to a port number. May
  340. * be an empty string, in which case all resolved endpoints will have a port
  341. * number of 0.
  342. *
  343. * @param resolve_flags A set of flags that determine how name resolution
  344. * should be performed. The default flags are suitable for communication with
  345. * remote hosts. See the @ref resolver_base documentation for the set of
  346. * available flags.
  347. *
  348. * @returns A range object representing the list of endpoint entries. A
  349. * successful call to this function is guaranteed to return a non-empty
  350. * range.
  351. *
  352. * @throws boost::system::system_error Thrown on failure.
  353. *
  354. * @note On POSIX systems, host names may be locally defined in the file
  355. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  356. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  357. * resolution is performed using DNS. Operating systems may use additional
  358. * locations when resolving host names (such as NETBIOS names on Windows).
  359. *
  360. * On POSIX systems, service names are typically defined in the file
  361. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  362. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  363. * may use additional locations when resolving service names.
  364. */
  365. results_type resolve(BOOST_ASIO_STRING_VIEW_PARAM host,
  366. BOOST_ASIO_STRING_VIEW_PARAM service, resolver_base::flags resolve_flags)
  367. {
  368. boost::system::error_code ec;
  369. basic_resolver_query<protocol_type> q(static_cast<std::string>(host),
  370. static_cast<std::string>(service), resolve_flags);
  371. results_type r = impl_.get_service().resolve(
  372. impl_.get_implementation(), q, ec);
  373. boost::asio::detail::throw_error(ec, "resolve");
  374. return r;
  375. }
  376. /// Perform forward resolution of a query to a list of entries.
  377. /**
  378. * This function is used to resolve host and service names into a list of
  379. * endpoint entries.
  380. *
  381. * @param host A string identifying a location. May be a descriptive name or
  382. * a numeric address string. If an empty string and the passive flag has been
  383. * specified, the resolved endpoints are suitable for local service binding.
  384. * If an empty string and passive is not specified, the resolved endpoints
  385. * will use the loopback address.
  386. *
  387. * @param service A string identifying the requested service. This may be a
  388. * descriptive name or a numeric string corresponding to a port number. May
  389. * be an empty string, in which case all resolved endpoints will have a port
  390. * number of 0.
  391. *
  392. * @param resolve_flags A set of flags that determine how name resolution
  393. * should be performed. The default flags are suitable for communication with
  394. * remote hosts. See the @ref resolver_base documentation for the set of
  395. * available flags.
  396. *
  397. * @param ec Set to indicate what error occurred, if any.
  398. *
  399. * @returns A range object representing the list of endpoint entries. An
  400. * empty range is returned if an error occurs. A successful call to this
  401. * function is guaranteed to return a non-empty range.
  402. *
  403. * @note On POSIX systems, host names may be locally defined in the file
  404. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  405. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  406. * resolution is performed using DNS. Operating systems may use additional
  407. * locations when resolving host names (such as NETBIOS names on Windows).
  408. *
  409. * On POSIX systems, service names are typically defined in the file
  410. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  411. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  412. * may use additional locations when resolving service names.
  413. */
  414. results_type resolve(BOOST_ASIO_STRING_VIEW_PARAM host,
  415. BOOST_ASIO_STRING_VIEW_PARAM service, resolver_base::flags resolve_flags,
  416. boost::system::error_code& ec)
  417. {
  418. basic_resolver_query<protocol_type> q(static_cast<std::string>(host),
  419. static_cast<std::string>(service), resolve_flags);
  420. return impl_.get_service().resolve(impl_.get_implementation(), q, ec);
  421. }
  422. /// Perform forward resolution of a query to a list of entries.
  423. /**
  424. * This function is used to resolve host and service names into a list of
  425. * endpoint entries.
  426. *
  427. * @param protocol A protocol object, normally representing either the IPv4 or
  428. * IPv6 version of an internet protocol.
  429. *
  430. * @param host A string identifying a location. May be a descriptive name or
  431. * a numeric address string. If an empty string and the passive flag has been
  432. * specified, the resolved endpoints are suitable for local service binding.
  433. * If an empty string and passive is not specified, the resolved endpoints
  434. * will use the loopback address.
  435. *
  436. * @param service A string identifying the requested service. This may be a
  437. * descriptive name or a numeric string corresponding to a port number. May
  438. * be an empty string, in which case all resolved endpoints will have a port
  439. * number of 0.
  440. *
  441. * @returns A range object representing the list of endpoint entries. A
  442. * successful call to this function is guaranteed to return a non-empty
  443. * range.
  444. *
  445. * @throws boost::system::system_error Thrown on failure.
  446. *
  447. * @note On POSIX systems, host names may be locally defined in the file
  448. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  449. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  450. * resolution is performed using DNS. Operating systems may use additional
  451. * locations when resolving host names (such as NETBIOS names on Windows).
  452. *
  453. * On POSIX systems, service names are typically defined in the file
  454. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  455. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  456. * may use additional locations when resolving service names.
  457. */
  458. results_type resolve(const protocol_type& protocol,
  459. BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service)
  460. {
  461. return resolve(protocol, host, service, resolver_base::flags());
  462. }
  463. /// Perform forward resolution of a query to a list of entries.
  464. /**
  465. * This function is used to resolve host and service names into a list of
  466. * endpoint entries.
  467. *
  468. * @param protocol A protocol object, normally representing either the IPv4 or
  469. * IPv6 version of an internet protocol.
  470. *
  471. * @param host A string identifying a location. May be a descriptive name or
  472. * a numeric address string. If an empty string and the passive flag has been
  473. * specified, the resolved endpoints are suitable for local service binding.
  474. * If an empty string and passive is not specified, the resolved endpoints
  475. * will use the loopback address.
  476. *
  477. * @param service A string identifying the requested service. This may be a
  478. * descriptive name or a numeric string corresponding to a port number. May
  479. * be an empty string, in which case all resolved endpoints will have a port
  480. * number of 0.
  481. *
  482. * @param ec Set to indicate what error occurred, if any.
  483. *
  484. * @returns A range object representing the list of endpoint entries. An
  485. * empty range is returned if an error occurs. A successful call to this
  486. * function is guaranteed to return a non-empty range.
  487. *
  488. * @note On POSIX systems, host names may be locally defined in the file
  489. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  490. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  491. * resolution is performed using DNS. Operating systems may use additional
  492. * locations when resolving host names (such as NETBIOS names on Windows).
  493. *
  494. * On POSIX systems, service names are typically defined in the file
  495. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  496. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  497. * may use additional locations when resolving service names.
  498. */
  499. results_type resolve(const protocol_type& protocol,
  500. BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service,
  501. boost::system::error_code& ec)
  502. {
  503. return resolve(protocol, host, service, resolver_base::flags(), ec);
  504. }
  505. /// Perform forward resolution of a query to a list of entries.
  506. /**
  507. * This function is used to resolve host and service names into a list of
  508. * endpoint entries.
  509. *
  510. * @param protocol A protocol object, normally representing either the IPv4 or
  511. * IPv6 version of an internet protocol.
  512. *
  513. * @param host A string identifying a location. May be a descriptive name or
  514. * a numeric address string. If an empty string and the passive flag has been
  515. * specified, the resolved endpoints are suitable for local service binding.
  516. * If an empty string and passive is not specified, the resolved endpoints
  517. * will use the loopback address.
  518. *
  519. * @param service A string identifying the requested service. This may be a
  520. * descriptive name or a numeric string corresponding to a port number. May
  521. * be an empty string, in which case all resolved endpoints will have a port
  522. * number of 0.
  523. *
  524. * @param resolve_flags A set of flags that determine how name resolution
  525. * should be performed. The default flags are suitable for communication with
  526. * remote hosts. See the @ref resolver_base documentation for the set of
  527. * available flags.
  528. *
  529. * @returns A range object representing the list of endpoint entries. A
  530. * successful call to this function is guaranteed to return a non-empty
  531. * range.
  532. *
  533. * @throws boost::system::system_error Thrown on failure.
  534. *
  535. * @note On POSIX systems, host names may be locally defined in the file
  536. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  537. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  538. * resolution is performed using DNS. Operating systems may use additional
  539. * locations when resolving host names (such as NETBIOS names on Windows).
  540. *
  541. * On POSIX systems, service names are typically defined in the file
  542. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  543. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  544. * may use additional locations when resolving service names.
  545. */
  546. results_type resolve(const protocol_type& protocol,
  547. BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service,
  548. resolver_base::flags resolve_flags)
  549. {
  550. boost::system::error_code ec;
  551. basic_resolver_query<protocol_type> q(
  552. protocol, static_cast<std::string>(host),
  553. static_cast<std::string>(service), resolve_flags);
  554. results_type r = impl_.get_service().resolve(
  555. impl_.get_implementation(), q, ec);
  556. boost::asio::detail::throw_error(ec, "resolve");
  557. return r;
  558. }
  559. /// Perform forward resolution of a query to a list of entries.
  560. /**
  561. * This function is used to resolve host and service names into a list of
  562. * endpoint entries.
  563. *
  564. * @param protocol A protocol object, normally representing either the IPv4 or
  565. * IPv6 version of an internet protocol.
  566. *
  567. * @param host A string identifying a location. May be a descriptive name or
  568. * a numeric address string. If an empty string and the passive flag has been
  569. * specified, the resolved endpoints are suitable for local service binding.
  570. * If an empty string and passive is not specified, the resolved endpoints
  571. * will use the loopback address.
  572. *
  573. * @param service A string identifying the requested service. This may be a
  574. * descriptive name or a numeric string corresponding to a port number. May
  575. * be an empty string, in which case all resolved endpoints will have a port
  576. * number of 0.
  577. *
  578. * @param resolve_flags A set of flags that determine how name resolution
  579. * should be performed. The default flags are suitable for communication with
  580. * remote hosts. See the @ref resolver_base documentation for the set of
  581. * available flags.
  582. *
  583. * @param ec Set to indicate what error occurred, if any.
  584. *
  585. * @returns A range object representing the list of endpoint entries. An
  586. * empty range is returned if an error occurs. A successful call to this
  587. * function is guaranteed to return a non-empty range.
  588. *
  589. * @note On POSIX systems, host names may be locally defined in the file
  590. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  591. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  592. * resolution is performed using DNS. Operating systems may use additional
  593. * locations when resolving host names (such as NETBIOS names on Windows).
  594. *
  595. * On POSIX systems, service names are typically defined in the file
  596. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  597. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  598. * may use additional locations when resolving service names.
  599. */
  600. results_type resolve(const protocol_type& protocol,
  601. BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service,
  602. resolver_base::flags resolve_flags, boost::system::error_code& ec)
  603. {
  604. basic_resolver_query<protocol_type> q(
  605. protocol, static_cast<std::string>(host),
  606. static_cast<std::string>(service), resolve_flags);
  607. return impl_.get_service().resolve(impl_.get_implementation(), q, ec);
  608. }
  609. #if !defined(BOOST_ASIO_NO_DEPRECATED)
  610. /// (Deprecated: Use overload with separate host and service parameters.)
  611. /// Asynchronously perform forward resolution of a query to a list of entries.
  612. /**
  613. * This function is used to asynchronously resolve a query into a list of
  614. * endpoint entries.
  615. *
  616. * @param q A query object that determines what endpoints will be returned.
  617. *
  618. * @param handler The handler to be called when the resolve operation
  619. * completes. Copies will be made of the handler as required. The function
  620. * signature of the handler must be:
  621. * @code void handler(
  622. * const boost::system::error_code& error, // Result of operation.
  623. * resolver::results_type results // Resolved endpoints as a range.
  624. * ); @endcode
  625. * Regardless of whether the asynchronous operation completes immediately or
  626. * not, the handler will not be invoked from within this function. On
  627. * immediate completion, invocation of the handler will be performed in a
  628. * manner equivalent to using boost::asio::post().
  629. *
  630. * A successful resolve operation is guaranteed to pass a non-empty range to
  631. * the handler.
  632. */
  633. template <
  634. BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
  635. results_type)) ResolveHandler
  636. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
  637. BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ResolveHandler,
  638. void (boost::system::error_code, results_type))
  639. async_resolve(const query& q,
  640. BOOST_ASIO_MOVE_ARG(ResolveHandler) handler
  641. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
  642. {
  643. return boost::asio::async_initiate<ResolveHandler,
  644. void (boost::system::error_code, results_type)>(
  645. initiate_async_resolve(this), handler, q);
  646. }
  647. #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
  648. /// Asynchronously perform forward resolution of a query to a list of entries.
  649. /**
  650. * This function is used to resolve host and service names into a list of
  651. * endpoint entries.
  652. *
  653. * @param host A string identifying a location. May be a descriptive name or
  654. * a numeric address string. If an empty string and the passive flag has been
  655. * specified, the resolved endpoints are suitable for local service binding.
  656. * If an empty string and passive is not specified, the resolved endpoints
  657. * will use the loopback address.
  658. *
  659. * @param service A string identifying the requested service. This may be a
  660. * descriptive name or a numeric string corresponding to a port number. May
  661. * be an empty string, in which case all resolved endpoints will have a port
  662. * number of 0.
  663. *
  664. * @param handler The handler to be called when the resolve operation
  665. * completes. Copies will be made of the handler as required. The function
  666. * signature of the handler must be:
  667. * @code void handler(
  668. * const boost::system::error_code& error, // Result of operation.
  669. * resolver::results_type results // Resolved endpoints as a range.
  670. * ); @endcode
  671. * Regardless of whether the asynchronous operation completes immediately or
  672. * not, the handler will not be invoked from within this function. On
  673. * immediate completion, invocation of the handler will be performed in a
  674. * manner equivalent to using boost::asio::post().
  675. *
  676. * A successful resolve operation is guaranteed to pass a non-empty range to
  677. * the handler.
  678. *
  679. * @note On POSIX systems, host names may be locally defined in the file
  680. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  681. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  682. * resolution is performed using DNS. Operating systems may use additional
  683. * locations when resolving host names (such as NETBIOS names on Windows).
  684. *
  685. * On POSIX systems, service names are typically defined in the file
  686. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  687. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  688. * may use additional locations when resolving service names.
  689. */
  690. template <
  691. BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
  692. results_type)) ResolveHandler
  693. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
  694. BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ResolveHandler,
  695. void (boost::system::error_code, results_type))
  696. async_resolve(BOOST_ASIO_STRING_VIEW_PARAM host,
  697. BOOST_ASIO_STRING_VIEW_PARAM service,
  698. BOOST_ASIO_MOVE_ARG(ResolveHandler) handler
  699. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
  700. {
  701. return async_resolve(host, service, resolver_base::flags(),
  702. BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
  703. }
  704. /// Asynchronously perform forward resolution of a query to a list of entries.
  705. /**
  706. * This function is used to resolve host and service names into a list of
  707. * endpoint entries.
  708. *
  709. * @param host A string identifying a location. May be a descriptive name or
  710. * a numeric address string. If an empty string and the passive flag has been
  711. * specified, the resolved endpoints are suitable for local service binding.
  712. * If an empty string and passive is not specified, the resolved endpoints
  713. * will use the loopback address.
  714. *
  715. * @param service A string identifying the requested service. This may be a
  716. * descriptive name or a numeric string corresponding to a port number. May
  717. * be an empty string, in which case all resolved endpoints will have a port
  718. * number of 0.
  719. *
  720. * @param resolve_flags A set of flags that determine how name resolution
  721. * should be performed. The default flags are suitable for communication with
  722. * remote hosts. See the @ref resolver_base documentation for the set of
  723. * available flags.
  724. *
  725. * @param handler The handler to be called when the resolve operation
  726. * completes. Copies will be made of the handler as required. The function
  727. * signature of the handler must be:
  728. * @code void handler(
  729. * const boost::system::error_code& error, // Result of operation.
  730. * resolver::results_type results // Resolved endpoints as a range.
  731. * ); @endcode
  732. * Regardless of whether the asynchronous operation completes immediately or
  733. * not, the handler will not be invoked from within this function. On
  734. * immediate completion, invocation of the handler will be performed in a
  735. * manner equivalent to using boost::asio::post().
  736. *
  737. * A successful resolve operation is guaranteed to pass a non-empty range to
  738. * the handler.
  739. *
  740. * @note On POSIX systems, host names may be locally defined in the file
  741. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  742. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  743. * resolution is performed using DNS. Operating systems may use additional
  744. * locations when resolving host names (such as NETBIOS names on Windows).
  745. *
  746. * On POSIX systems, service names are typically defined in the file
  747. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  748. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  749. * may use additional locations when resolving service names.
  750. */
  751. template <
  752. BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
  753. results_type)) ResolveHandler
  754. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
  755. BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ResolveHandler,
  756. void (boost::system::error_code, results_type))
  757. async_resolve(BOOST_ASIO_STRING_VIEW_PARAM host,
  758. BOOST_ASIO_STRING_VIEW_PARAM service,
  759. resolver_base::flags resolve_flags,
  760. BOOST_ASIO_MOVE_ARG(ResolveHandler) handler
  761. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
  762. {
  763. basic_resolver_query<protocol_type> q(static_cast<std::string>(host),
  764. static_cast<std::string>(service), resolve_flags);
  765. return boost::asio::async_initiate<ResolveHandler,
  766. void (boost::system::error_code, results_type)>(
  767. initiate_async_resolve(this), handler, q);
  768. }
  769. /// Asynchronously perform forward resolution of a query to a list of entries.
  770. /**
  771. * This function is used to resolve host and service names into a list of
  772. * endpoint entries.
  773. *
  774. * @param protocol A protocol object, normally representing either the IPv4 or
  775. * IPv6 version of an internet protocol.
  776. *
  777. * @param host A string identifying a location. May be a descriptive name or
  778. * a numeric address string. If an empty string and the passive flag has been
  779. * specified, the resolved endpoints are suitable for local service binding.
  780. * If an empty string and passive is not specified, the resolved endpoints
  781. * will use the loopback address.
  782. *
  783. * @param service A string identifying the requested service. This may be a
  784. * descriptive name or a numeric string corresponding to a port number. May
  785. * be an empty string, in which case all resolved endpoints will have a port
  786. * number of 0.
  787. *
  788. * @param handler The handler to be called when the resolve operation
  789. * completes. Copies will be made of the handler as required. The function
  790. * signature of the handler must be:
  791. * @code void handler(
  792. * const boost::system::error_code& error, // Result of operation.
  793. * resolver::results_type results // Resolved endpoints as a range.
  794. * ); @endcode
  795. * Regardless of whether the asynchronous operation completes immediately or
  796. * not, the handler will not be invoked from within this function. On
  797. * immediate completion, invocation of the handler will be performed in a
  798. * manner equivalent to using boost::asio::post().
  799. *
  800. * A successful resolve operation is guaranteed to pass a non-empty range to
  801. * the handler.
  802. *
  803. * @note On POSIX systems, host names may be locally defined in the file
  804. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  805. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  806. * resolution is performed using DNS. Operating systems may use additional
  807. * locations when resolving host names (such as NETBIOS names on Windows).
  808. *
  809. * On POSIX systems, service names are typically defined in the file
  810. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  811. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  812. * may use additional locations when resolving service names.
  813. */
  814. template <
  815. BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
  816. results_type)) ResolveHandler
  817. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
  818. BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ResolveHandler,
  819. void (boost::system::error_code, results_type))
  820. async_resolve(const protocol_type& protocol,
  821. BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service,
  822. BOOST_ASIO_MOVE_ARG(ResolveHandler) handler
  823. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
  824. {
  825. return async_resolve(protocol, host, service, resolver_base::flags(),
  826. BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
  827. }
  828. /// Asynchronously perform forward resolution of a query to a list of entries.
  829. /**
  830. * This function is used to resolve host and service names into a list of
  831. * endpoint entries.
  832. *
  833. * @param protocol A protocol object, normally representing either the IPv4 or
  834. * IPv6 version of an internet protocol.
  835. *
  836. * @param host A string identifying a location. May be a descriptive name or
  837. * a numeric address string. If an empty string and the passive flag has been
  838. * specified, the resolved endpoints are suitable for local service binding.
  839. * If an empty string and passive is not specified, the resolved endpoints
  840. * will use the loopback address.
  841. *
  842. * @param service A string identifying the requested service. This may be a
  843. * descriptive name or a numeric string corresponding to a port number. May
  844. * be an empty string, in which case all resolved endpoints will have a port
  845. * number of 0.
  846. *
  847. * @param resolve_flags A set of flags that determine how name resolution
  848. * should be performed. The default flags are suitable for communication with
  849. * remote hosts. See the @ref resolver_base documentation for the set of
  850. * available flags.
  851. *
  852. * @param handler The handler to be called when the resolve operation
  853. * completes. Copies will be made of the handler as required. The function
  854. * signature of the handler must be:
  855. * @code void handler(
  856. * const boost::system::error_code& error, // Result of operation.
  857. * resolver::results_type results // Resolved endpoints as a range.
  858. * ); @endcode
  859. * Regardless of whether the asynchronous operation completes immediately or
  860. * not, the handler will not be invoked from within this function. On
  861. * immediate completion, invocation of the handler will be performed in a
  862. * manner equivalent to using boost::asio::post().
  863. *
  864. * A successful resolve operation is guaranteed to pass a non-empty range to
  865. * the handler.
  866. *
  867. * @note On POSIX systems, host names may be locally defined in the file
  868. * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
  869. * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
  870. * resolution is performed using DNS. Operating systems may use additional
  871. * locations when resolving host names (such as NETBIOS names on Windows).
  872. *
  873. * On POSIX systems, service names are typically defined in the file
  874. * <tt>/etc/services</tt>. On Windows, service names may be found in the file
  875. * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
  876. * may use additional locations when resolving service names.
  877. */
  878. template <
  879. BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
  880. results_type)) ResolveHandler
  881. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
  882. BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ResolveHandler,
  883. void (boost::system::error_code, results_type))
  884. async_resolve(const protocol_type& protocol,
  885. BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service,
  886. resolver_base::flags resolve_flags,
  887. BOOST_ASIO_MOVE_ARG(ResolveHandler) handler
  888. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
  889. {
  890. basic_resolver_query<protocol_type> q(
  891. protocol, static_cast<std::string>(host),
  892. static_cast<std::string>(service), resolve_flags);
  893. return boost::asio::async_initiate<ResolveHandler,
  894. void (boost::system::error_code, results_type)>(
  895. initiate_async_resolve(this), handler, q);
  896. }
  897. /// Perform reverse resolution of an endpoint to a list of entries.
  898. /**
  899. * This function is used to resolve an endpoint into a list of endpoint
  900. * entries.
  901. *
  902. * @param e An endpoint object that determines what endpoints will be
  903. * returned.
  904. *
  905. * @returns A range object representing the list of endpoint entries. A
  906. * successful call to this function is guaranteed to return a non-empty
  907. * range.
  908. *
  909. * @throws boost::system::system_error Thrown on failure.
  910. */
  911. results_type resolve(const endpoint_type& e)
  912. {
  913. boost::system::error_code ec;
  914. results_type i = impl_.get_service().resolve(
  915. impl_.get_implementation(), e, ec);
  916. boost::asio::detail::throw_error(ec, "resolve");
  917. return i;
  918. }
  919. /// Perform reverse resolution of an endpoint to a list of entries.
  920. /**
  921. * This function is used to resolve an endpoint into a list of endpoint
  922. * entries.
  923. *
  924. * @param e An endpoint object that determines what endpoints will be
  925. * returned.
  926. *
  927. * @param ec Set to indicate what error occurred, if any.
  928. *
  929. * @returns A range object representing the list of endpoint entries. An
  930. * empty range is returned if an error occurs. A successful call to this
  931. * function is guaranteed to return a non-empty range.
  932. */
  933. results_type resolve(const endpoint_type& e, boost::system::error_code& ec)
  934. {
  935. return impl_.get_service().resolve(impl_.get_implementation(), e, ec);
  936. }
  937. /// Asynchronously perform reverse resolution of an endpoint to a list of
  938. /// entries.
  939. /**
  940. * This function is used to asynchronously resolve an endpoint into a list of
  941. * endpoint entries.
  942. *
  943. * @param e An endpoint object that determines what endpoints will be
  944. * returned.
  945. *
  946. * @param handler The handler to be called when the resolve operation
  947. * completes. Copies will be made of the handler as required. The function
  948. * signature of the handler must be:
  949. * @code void handler(
  950. * const boost::system::error_code& error, // Result of operation.
  951. * resolver::results_type results // Resolved endpoints as a range.
  952. * ); @endcode
  953. * Regardless of whether the asynchronous operation completes immediately or
  954. * not, the handler will not be invoked from within this function. On
  955. * immediate completion, invocation of the handler will be performed in a
  956. * manner equivalent to using boost::asio::post().
  957. *
  958. * A successful resolve operation is guaranteed to pass a non-empty range to
  959. * the handler.
  960. */
  961. template <
  962. BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
  963. results_type)) ResolveHandler
  964. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
  965. BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ResolveHandler,
  966. void (boost::system::error_code, results_type))
  967. async_resolve(const endpoint_type& e,
  968. BOOST_ASIO_MOVE_ARG(ResolveHandler) handler
  969. BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
  970. {
  971. return boost::asio::async_initiate<ResolveHandler,
  972. void (boost::system::error_code, results_type)>(
  973. initiate_async_resolve(this), handler, e);
  974. }
  975. private:
  976. // Disallow copying and assignment.
  977. basic_resolver(const basic_resolver&) BOOST_ASIO_DELETED;
  978. basic_resolver& operator=(const basic_resolver&) BOOST_ASIO_DELETED;
  979. class initiate_async_resolve
  980. {
  981. public:
  982. typedef Executor executor_type;
  983. explicit initiate_async_resolve(basic_resolver* self)
  984. : self_(self)
  985. {
  986. }
  987. executor_type get_executor() const BOOST_ASIO_NOEXCEPT
  988. {
  989. return self_->get_executor();
  990. }
  991. template <typename ResolveHandler, typename Query>
  992. void operator()(BOOST_ASIO_MOVE_ARG(ResolveHandler) handler,
  993. const Query& q) const
  994. {
  995. // If you get an error on the following line it means that your handler
  996. // does not meet the documented type requirements for a ResolveHandler.
  997. BOOST_ASIO_RESOLVE_HANDLER_CHECK(
  998. ResolveHandler, handler, results_type) type_check;
  999. boost::asio::detail::non_const_lvalue<ResolveHandler> handler2(handler);
  1000. self_->impl_.get_service().async_resolve(
  1001. self_->impl_.get_implementation(), q,
  1002. handler2.value, self_->impl_.get_executor());
  1003. }
  1004. private:
  1005. basic_resolver* self_;
  1006. };
  1007. # if defined(BOOST_ASIO_WINDOWS_RUNTIME)
  1008. boost::asio::detail::io_object_impl<
  1009. boost::asio::detail::winrt_resolver_service<InternetProtocol>,
  1010. Executor> impl_;
  1011. # else
  1012. boost::asio::detail::io_object_impl<
  1013. boost::asio::detail::resolver_service<InternetProtocol>,
  1014. Executor> impl_;
  1015. # endif
  1016. };
  1017. } // namespace ip
  1018. } // namespace asio
  1019. } // namespace boost
  1020. #include <boost/asio/detail/pop_options.hpp>
  1021. #endif // BOOST_ASIO_IP_BASIC_RESOLVER_HPP