boost::corosio::resolver

An asynchronous DNS resolver for coroutine I/O.

Synopsis

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 using exceptions
auto results = (co_await r.resolve("www.example.com", "https")).value();

Base Classes

Name Description

io_object

Base class for platform I/O objects.

Types

Name

Description

handle

RAII wrapper for I/O object implementation lifetime.

implementation

Forward declaration for platform‐specific implementation.

io_object_impl

Base interface for platform I/O implementations.

io_service

Service interface for I/O object lifecycle management.

resolver_impl

Member Functions

Name

Description

resolver [constructor] [deleted]

Constructors

~resolver [destructor] [virtual]

Destructor.

operator= [deleted]

Move assignment operator.

cancel

Cancel any pending asynchronous operations.

context

Return the execution context.

resolve

resolve overloads

Protected Data Members

Name

ctx_

impl_

Created with MrDocs