E-MailRelay
|
A class for synchronous or asynchronous network name to address resolution. More...
#include <gresolver.h>
Classes | |
struct | Callback |
An interface used for GNet::Resolver callbacks. More... | |
Public Types | |
using | AddressList = std::vector< Address > |
Public Member Functions | |
Resolver (Callback &, ExceptionSink) | |
Constructor taking a callback interface reference. More... | |
~Resolver () | |
Destructor. More... | |
void | start (const Location &) |
Starts asynchronous name-to-address resolution. More... | |
bool | busy () const |
Returns true if there is a pending resolve request. More... | |
Resolver (const Resolver &)=delete | |
Resolver (Resolver &&)=delete | |
void | operator= (const Resolver &)=delete |
void | operator= (Resolver &&)=delete |
Static Public Member Functions | |
static std::string | resolve (Location &) |
Does synchronous name resolution. More... | |
static AddressList | resolve (const std::string &host, const std::string &service, int family=AF_UNSPEC, bool dgram=false) |
Does synchronous name resolution returning a list of addresses. More... | |
static bool | async () |
Returns true if the resolver supports asynchronous operation. More... | |
Friends | |
class | GNet::ResolverImp |
A class for synchronous or asynchronous network name to address resolution.
The implementation uses getaddrinfo() at its core, with std::thread used for asynchronous resolve requests, with hooks into the GNet::EventLoop via GNet::FutureEvent.
Definition at line 43 of file gresolver.h.
using GNet::Resolver::AddressList = std::vector<Address> |
Definition at line 46 of file gresolver.h.
GNet::Resolver::Resolver | ( | Resolver::Callback & | callback, |
ExceptionSink | es | ||
) |
Constructor taking a callback interface reference.
The exception sink is called if an exception is thrown out of Callback::onResolved().
Definition at line 174 of file gresolver.cpp.
GNet::Resolver::~Resolver | ( | ) |
Destructor.
The results of any pending asynchronous resolve request are discarded asynchronously, although in extreme cases this destructor may block doing a thread join.
Definition at line 181 of file gresolver.cpp.
|
static |
Returns true if the resolver supports asynchronous operation.
If it doesnt then start() will always throw.
Definition at line 255 of file gresolver.cpp.
bool GNet::Resolver::busy | ( | ) | const |
Returns true if there is a pending resolve request.
Definition at line 250 of file gresolver.cpp.
|
static |
Does synchronous name resolution returning a list of addresses.
Errors are not reported. The empty list is returned on error.
Definition at line 217 of file gresolver.cpp.
|
static |
Does synchronous name resolution.
Fills in the name and address fields of the supplied Location structure. The returned error string is zero length on success.
Definition at line 194 of file gresolver.cpp.
void GNet::Resolver::start | ( | const Location & | location | ) |
Starts asynchronous name-to-address resolution.
Precondition: async() && !busy()
Definition at line 231 of file gresolver.cpp.
|
friend |
Definition at line 96 of file gresolver.h.