basic_resolver.hpp 47 KB

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