boost::corosio::resolver
An asynchronous DNS resolver for coroutine I/O.
Synopsis
Declared in <boost/corosio/resolver.hpp>
class resolver
: public io_object
Description
This class provides asynchronous DNS resolution operations that return awaitable types. Each operation participates in the affine awaitable protocol, ensuring coroutines resume on the correct executor.
Thread Safety
Distinct objects: Safe. Shared objects: Unsafe. A resolver must not have concurrent resolve operations.
Semantics
Wraps platform DNS resolution (getaddrinfo/getnameinfo). Operations dispatch to OS resolver APIs via the io_context thread pool.
Example
io_context ioc;
resolver r(ioc);
// Using structured bindings
auto [ec, results] = co_await r.resolve("www.example.com", "https");
if (ec)
co_return;
for (auto const& entry : results)
std::cout << entry.get_endpoint().port() << std::endl;
// Or, to convert errors into exceptions:
auto [ec2, results2] = co_await r.resolve("www.example.com", "https");
if (ec2)
throw std::system_error(ec2);
Types
Name |
Description |
RAII wrapper for I/O object implementation lifetime. |
|
Backend interface for DNS resolution operations. |
|
Service interface for I/O object lifecycle management. |
Member Functions
Name |
Description |
|
Constructors |
|
Destructor. |
|
Move assignment operator. |
Cancel any pending asynchronous operations. |
|
Return the execution context. |
|
|
Protected Member Functions
Name |
Description |
|
Construct from |
|
Move assign from another I/O object. |
Protected Static Member Functions
Name |
Description |
Create a handle bound to a service found in the context. |
Derived Classes
Name |
Description |
An asynchronous DNS resolver with devirtualized operations. |
Created with MrDocs