E-MailRelay

Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
GNet::Resolver Class Reference

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...
struct | Config
| A configuration structure for GNet::Resolver. More...

## Public Types
using | AddressList = std::vector< Address >

## Public Member Functions
| Resolver (Callback &, EventState)
| Constructor taking a callback interface reference. More...
| ~Resolver ()
| Destructor. More...
void | start (const Location &, const Config &={})
| 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
Resolver & | operator= (const Resolver &)=delete
Resolver & | operator= (Resolver &&)=delete

## Static Public Member Functions
static std::pair< std::string, std::string > | resolve (Location &, const Config &)
| Does synchronous name resolution. More...
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, const Config &={})
| Does synchronous name resolution returning a list of addresses. More...
static bool | async ()
| Returns true if the resolver supports asynchronous operation. More...

## Detailed Description

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 46 of file gresolver.h.

## Member Typedef Documentation

## ◆ AddressList

using GNet::Resolver::AddressList = std::vector<Address>

Definition at line 65 of file gresolver.h.

## Constructor & Destructor Documentation

## ◆ Resolver()

GNet::Resolver::Resolver | ( | Resolver::Callback & | callback,
|  | EventState | es
| ) |  |

Constructor taking a callback interface reference.

The exception sink is called if an exception is thrown out of Callback::onResolved().

Definition at line 173 of file gresolver.cpp.

## ◆ ~Resolver()

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 180 of file gresolver.cpp.

## Member Function Documentation

## ◆ async()

bool GNet::Resolver::async | ( |  | ) |
| static

Returns true if the resolver supports asynchronous operation.

If it doesnt then start() will always throw.

Definition at line 260 of file gresolver.cpp.

## ◆ busy()

bool GNet::Resolver::busy | ( |  | ) | const

Returns true if there is a pending resolve request.

Definition at line 255 of file gresolver.cpp.

## ◆ resolve() [1/3]

GNet::Resolver::AddressList GNet::Resolver::resolve | ( | const std::string & | host,
|  | const std::string & | service,
|  | int | family = `AF_UNSPEC`,
|  | const Config & | config = `{}`
| ) |  |
| static

Does synchronous name resolution returning a list of addresses.

Errors are not reported. The empty list is returned on error.

Definition at line 221 of file gresolver.cpp.

## ◆ resolve() [2/3]

std::string GNet::Resolver::resolve | ( | Location & | location | ) |
| static

Does synchronous name resolution.

Fills in the address of the supplied Location structure. Returns an error string, empty on success.

Definition at line 193 of file gresolver.cpp.

## ◆ resolve() [3/3]

std::pair< std::string, std::string > GNet::Resolver::resolve | ( | Location & | location,
|  | const Config & | config
| ) |  |
| static

Does synchronous name resolution.

Fills in the address of the supplied Location structure. Returns an error string (empty on success) and the canonical name, if requested (see Config::with_canonical_name).

Definition at line 198 of file gresolver.cpp.

## ◆ start()

void GNet::Resolver::start | ( | const Location & | location,
|  | const Config & | config = `{}`
| ) |  |

Starts asynchronous name-to-address resolution.

Precondition: async() && !busy()

Definition at line 236 of file gresolver.cpp.

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

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/gresolver.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/gresolver.cpp