trantor
Non-blocking I/O cross-platform TCP network library, using C++14
Loading...
Searching...
No Matches
trantor::Resolver Class Referenceabstract

This class represents an asynchronous DNS resolver. More...

#include <trantor/net/Resolver.h>

Public Types

using Callback = std::function<void(const trantor::InetAddress&)>
using ResolverResultsCallback

Public Member Functions

virtual void resolve (const std::string &hostname, const Callback &callback)=0
 Resolve an address asynchronously.
virtual void resolve (const std::string &hostname, const ResolverResultsCallback &callback)=0
 Resolve an address array asynchronously.

Static Public Member Functions

static std::shared_ptr< ResolvernewResolver (EventLoop *loop=nullptr, size_t timeout=60)
 Create a new DNS resolver.
static bool isCAresUsed ()
 Check whether the c-ares library is used.

Detailed Description

This class represents an asynchronous DNS resolver.

Note
Although the c-ares library is not essential, it is recommended to install it for higher performance

Member Typedef Documentation

◆ ResolverResultsCallback

using trantor::Resolver::ResolverResultsCallback
Initial value:
std::function<void(const std::vector<trantor::InetAddress>&)>

Member Function Documentation

◆ isCAresUsed()

bool trantor::Resolver::isCAresUsed ( )
static

Check whether the c-ares library is used.

Returns
true
false

◆ newResolver()

std::shared_ptr< Resolver > trantor::Resolver::newResolver ( EventLoop * loop = nullptr,
size_t timeout = 60 )
static

Create a new DNS resolver.

Parameters
loopThe event loop in which the DNS resolver runs.
timeoutThe timeout in seconds for DNS.
Returns
std::shared_ptr<Resolver>

◆ resolve() [1/2]

virtual void trantor::Resolver::resolve ( const std::string & hostname,
const Callback & callback )
pure virtual

Resolve an address asynchronously.

Parameters
hostname
callback

◆ resolve() [2/2]

virtual void trantor::Resolver::resolve ( const std::string & hostname,
const ResolverResultsCallback & callback )
pure virtual

Resolve an address array asynchronously.

Parameters
hostname
callback

The documentation for this class was generated from the following file: