21#ifndef G_NET_RESOLVER_H
22#define G_NET_RESOLVER_H
49 G_EXCEPTION( Error ,
tx(
"asynchronous resolver error") )
50 G_EXCEPTION( BusyError ,
tx(
"asynchronous resolver still busy") )
54 bool with_canonical_name {
false} ;
56 bool datagram {
false} ;
57 bool idn_flag {
false} ;
58 bool test_slow {
false} ;
59 Config & set_with_canonical_name(
bool =
true ) noexcept ;
60 Config & set_raw(
bool =
true ) noexcept ;
61 Config & set_convert_to_punycode(
bool =
true ) noexcept ;
62 Config & set_datagram(
bool =
true ) noexcept ;
63 Config & set_idn_flag(
bool =
true ) noexcept ;
65 using AddressList = std::vector<Address> ;
89 static std::pair<std::string,std::string>
resolve(
Location & ,
const Config & ) ;
100 static AddressList
resolve(
const std::string & host ,
const std::string & service ,
int family = AF_UNSPEC ,
const Config & = {} ) ;
105 static bool async() ;
119 friend class GNet::ResolverImp ;
120 void done(
const std::string & ,
const Location & ) ;
123 Callback & m_callback ;
125 std::unique_ptr<ResolverImp> m_imp ;
128inline GNet::Resolver::Config & GNet::Resolver::Config::set_with_canonical_name(
bool b )
noexcept { with_canonical_name = b ;
return *this ; }
129inline GNet::Resolver::Config & GNet::Resolver::Config::set_raw(
bool b )
noexcept { raw = b ;
return *this ; }
130inline GNet::Resolver::Config & GNet::Resolver::Config::set_datagram(
bool b )
noexcept { datagram = b ;
return *this ; }
131inline GNet::Resolver::Config & GNet::Resolver::Config::set_idn_flag(
bool b )
noexcept { idn_flag = b ;
return *this ; }
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
A class that represents the remote target for out-going client connections.
A class for synchronous or asynchronous network name to address resolution.
Resolver(Callback &, EventState)
Constructor taking a callback interface reference.
static std::pair< std::string, std::string > resolve(Location &, const Config &)
Does synchronous name resolution.
void start(const Location &, const Config &={})
Starts asynchronous name-to-address resolution.
static bool async()
Returns true if the resolver supports asynchronous operation.
bool busy() const
Returns true if there is a pending resolve request.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
An interface used for GNet::Resolver callbacks.
virtual ~Callback()=default
Destructor.
virtual void onResolved(std::string error, Location)=0
Called on completion of GNet::Resolver name resolution.
A configuration structure for GNet::Resolver.