Template Class base_resolver¶
Defined in File resolver.hpp
Inheritance Relationships¶
Base Type¶
public stream_client::detail::timed_base< Clock >
(Template Class timed_base)
Class Documentation¶
-
template<typename
Protocol
>
classstream_client::resolver
::
base_resolver
: public stream_client::detail::timed_base<Clock>¶ DNS resolver.
This class wraps usage of boost::asio::ip::basic_resolver to make it timeout-blocked. Used to resolve a hostname:port pair to an iterator of endpoints.
Note
Not thread-safe, concurrent calls of resolve() may mess up timeout handling.
- tparam Protocol
Type of result endpoints.
Public Types
-
using
resolver_type
= boost::asio::ip::basic_resolver<protocol_type>¶
-
using
query_type
= typename resolver_type::query¶
-
using
resolve_flags_type
= typename query_type::flags¶
-
using
iterator_type
= typename resolver_type::iterator¶
Public Functions
-
base_resolver
(std::string host, std::string port, time_duration_type resolve_timeout, ip_family protocol = kDefaultIPFamily, resolve_flags_type resolve_flags = kDefaultFlags)¶ Parametrized constructor.
Stores remote parameters needed for resolving. Doesn’t do actual resolution, to make it happen call resolve() on constructed instance.
- Parameters
[in] host – Remote hostname.
[in] port – Remote port used in resolved endpoints.
[in] resolve_timeout – Default resolve timeout.
[in] protocol – Family of IP protocol to resolve (ipv4, ipv6 or any).
[in] resolve_flags – A set of flags that determine how name resolution should be performed.
-
base_resolver
(const base_resolver<Protocol> &other) = delete¶ Copy constructor is not permitted.
-
base_resolver<Protocol> &
operator=
(const base_resolver<Protocol> &other) = delete¶ Copy assignment is not permitted.
-
base_resolver
(base_resolver<Protocol> &&other) = default¶ Move constructor.
-
base_resolver<Protocol> &
operator=
(base_resolver<Protocol> &&other) = default¶ Move assignment.
-
virtual
~base_resolver
() = default¶ Destructor.
-
template<typename
Time
>
iterator_typeresolve
(boost::system::error_code &ec, const Time &timeout_or_deadline)¶ Perform DNS resolve.
Resolve stored hostname into iterator of address:port pairs within specified timeout.
Note
A successful call to this function is guaranteed to return at least one entry.
- Template Parameters
Time – Type of
timeout_or_deadline
, either time_duration_type or time_point_type.- Parameters
[in] timeout_or_deadline – Expiration time-point or duration.
[out] ec – Set to indicate what error occurred, if any.
- Returns
A forward-only iterator that can be used to traverse the list of endpoint entries. Returns a default constructed iterator if an error occurs.
-
inline iterator_type
resolve
(boost::system::error_code &ec)¶ Perform DNS resolve.
Resolve stored hostname into iterator of address:port pairs within default timeout. Timeout can be manipulated with resolve_timeout().
Note
A successful call to this function is guaranteed to return at least one entry.
- Parameters
[out] ec – Set to indicate what error occurred, if any.
- Returns
A forward-only iterator that can be used to traverse the list of endpoint entries. Returns a default constructed iterator if an error occurs.
-
inline iterator_type
resolve
()¶ Perform DNS resolve.
Resolve stored hostname into iterator of address:port pairs within default timeout. Timeout can be manipulated with resolve_timeout().
Note
A successful call to this function is guaranteed to return at least one entry.
- Parameters
[out] ec – Set to indicate what error occurred, if any.
- Throws
boost::system::system_error – Thrown on failure.
Public Static Attributes
-
static const resolve_flags_type
kDefaultFlags
= resolve_flags_type::address_configured¶ Default flags to use with internal DNS query.