glibmm 2.80.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gio::Resolver Class Reference

Asynchronous and cancellable DNS resolver. More...

#include <giomm/resolver.h>

Inheritance diagram for Gio::Resolver:
Inheritance graph
[legend]

Public Types

enum class  RecordType {
  SRV = 1 ,
  MX ,
  TXT ,
  SOA ,
  NS
}
 
enum class  NameLookupFlags {
  DEFAULT = 0x0 ,
  IPV4_ONLY = 1 << 0 ,
  IPV6_ONLY = 1 << 1
}
 
- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(gpointer data)
 

Public Member Functions

 Resolver (Resolver &&src) noexcept
 
Resolveroperator= (Resolver &&src) noexcept
 
 ~Resolver () noexcept override
 
GResolvergobj ()
 Provides access to the underlying C GObject.
 
const GResolvergobj () const
 Provides access to the underlying C GObject.
 
GResolvergobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
std::vector< Glib::RefPtr< InetAddress > > lookup_by_name (const Glib::ustring &hostname, const Glib::RefPtr< Cancellable > &cancellable)
 Synchronously resolves hostname to determine its associated IP address(es).
 
std::vector< Glib::RefPtr< InetAddress > > lookup_by_name (const Glib::ustring &hostname)
 A lookup_by_name() convenience overload.
 
void lookup_by_name_async (const Glib::ustring &hostname, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable)
 Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls slot, which must call lookup_by_name_finish() to get the result.
 
void lookup_by_name_async (const Glib::ustring &hostname, const SlotAsyncReady &slot)
 Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls slot, which must call lookup_by_name_finish() to get the result.
 
std::vector< Glib::RefPtr< InetAddress > > lookup_by_name_finish (const Glib::RefPtr< AsyncResult > &result)
 Retrieves the result of a call to g_resolver_lookup_by_name_async().
 
std::vector< Glib::RefPtr< InetAddress > > lookup_by_name_with_flags (const Glib::ustring &hostname, NameLookupFlags flags, const Glib::RefPtr< Cancellable > &cancellable={})
 This differs from g_resolver_lookup_by_name() in that you can modify the lookup behavior with flags.
 
void lookup_by_name_with_flags_async (const Glib::ustring &hostname, NameLookupFlags flags, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable={})
 Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls slot, which must call g_resolver_lookup_by_name_with_flags_finish() to get the result.
 
std::vector< Glib::RefPtr< InetAddress > > lookup_by_name_with_flags_finish (const Glib::RefPtr< AsyncResult > &result)
 Retrieves the result of a call to g_resolver_lookup_by_name_with_flags_async().
 
Glib::ustring lookup_by_address (const Glib::RefPtr< InetAddress > &address, const Glib::RefPtr< Cancellable > &cancellable)
 Synchronously reverse-resolves address to determine its associated hostname.
 
Glib::ustring lookup_by_address (const Glib::RefPtr< InetAddress > &address)
 A lookup_by_address() convenience overload.
 
void lookup_by_address_async (const Glib::RefPtr< InetAddress > &address, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable)
 Begins asynchronously reverse-resolving an address to determine its associated hostname, and eventually calls callback, which must call lookup_by_address_finish() to get the final result.
 
void lookup_by_address_async (const Glib::RefPtr< InetAddress > &address, const SlotAsyncReady &slot)
 Begins asynchronously reverse-resolving an address to determine its associated hostname, and eventually calls callback, which must call lookup_by_address_finish() to get the final result.
 
Glib::ustring lookup_by_address_finish (const Glib::RefPtr< AsyncResult > &result)
 Retrieves the result of a previous call to g_resolver_lookup_by_address_async().
 
std::vector< SrvTargetlookup_service (const Glib::ustring &service, const Glib::ustring &protocol, const Glib::ustring & domain, const Glib::RefPtr< Cancellable > &cancellable)
 Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of SrvTarget.
 
std::vector< SrvTargetlookup_service (const Glib::ustring &service, const Glib::ustring &protocol, const Glib::ustring & domain)
 A lookup_service() convenience overload.
 
void lookup_service_async (const Glib::ustring &service, const Glib::ustring &protocol, const Glib::ustring & domain, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable)
 Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, which must call lookup_service_finish() to get the final result.
 
void lookup_service_async (const Glib::ustring &service, const Glib::ustring &protocol, const Glib::ustring & domain, const SlotAsyncReady &slot)
 Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, which must call lookup_service_finish() to get the final result.
 
std::vector< SrvTargetlookup_service_finish (const Glib::RefPtr< AsyncResult > &result)
 Retrieves the result of a previous call to g_resolver_lookup_service_async().
 
std::vector< Glib::VariantContainerBaselookup_records (const Glib::ustring &rrname, RecordType record_type, const Glib::RefPtr< Cancellable > &cancellable)
 Synchronously performs a DNS record lookup for the given rrname and returns a list of records as Variant tuples.
 
std::vector< Glib::VariantContainerBaselookup_records (const Glib::ustring &rrname, RecordType record_type)
 A lookup_records() convenience overload.
 
void lookup_records_async (const Glib::ustring &rrname, RecordType record_type, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable)
 Begins asynchronously performing a DNS lookup for the given rrname, and eventually calls slot, which must call lookup_records_finish() to get the final result.
 
void lookup_records_async (const Glib::ustring &rrname, RecordType record_type, const SlotAsyncReady &slot)
 A non-cancellable version of lookup_records_async().
 
std::vector< Glib::VariantContainerBaselookup_records_finish (const Glib::RefPtr< AsyncResult > &result)
 Retrieves the result of a previous call to g_resolver_lookup_records_async().
 
unsigned get_timeout () const
 Get the timeout applied to all resolver lookups.
 
void set_timeout (unsigned timeout_ms)
 Set the timeout applied to all resolver lookups.
 
Glib::PropertyProxy< unsigned intproperty_timeout ()
 The timeout applied to all resolver lookups, in milliseconds.
 
Glib::PropertyProxy_ReadOnly< unsigned intproperty_timeout () const
 The timeout applied to all resolver lookups, in milliseconds.
 
Glib::SignalProxy< void()> signal_reload ()
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
voidget_data (const QueryQuark & key)
 
void set_data (const Quark & key, void *data)
 
void set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify)
 
void set_data (const Quark & key, void *data, DestroyNotify notify)
 Prefer set_data_with_c_callback() with a callback with C linkage.
 
void remove_data (const QueryQuark &quark)
 
voidsteal_data (const QueryQuark &quark)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value)
 You probably want to use a specific property_*() accessor method instead.
 
void get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const
 You probably want to use a specific property_*() accessor method instead.
 
template<class PropertyType >
void set_property (const Glib::ustring & property_name, const PropertyType & value)
 You probably want to use a specific property_*() accessor method instead.
 
template<class PropertyType >
void get_property (const Glib::ustring & property_name, PropertyType & value) const
 You probably want to use a specific property_*() accessor method instead.
 
template<class PropertyType >
PropertyType get_property (const Glib::ustring & property_name) const
 You probably want to use a specific property_*() accessor method instead.
 
sigc::connection connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> &slot)
 You can use the signal_changed() signal of the property proxy instead.
 
sigc::connection connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot)
 You can use the signal_changed() signal of the property proxy instead.
 
void freeze_notify ()
 Increases the freeze count on object.
 
void thaw_notify ()
 Reverts the effect of a previous call to freeze_notify().
 
virtual void reference () const
 Increment the reference count for this object.
 
virtual void unreference () const
 Decrement the reference count for this object.
 
GObject * gobj ()
 Provides access to the underlying C GObject.
 
const GObject * gobj () const
 Provides access to the underlying C GObject.
 
GObject * gobj_copy () const
 Give a ref-ed copy to someone. Use for direct struct access.
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 
static Glib::RefPtr< Resolverget_default ()
 
static void set_default (const Glib::RefPtr< Resolver > &resolver)
 

Protected Member Functions

virtual void on_reload ()
 This is a default handler for the signal signal_reload().
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor.
 
 ObjectBase (const char *custom_type_name)
 A derived constructor always overrides this choice.
 
 ObjectBase (const std::type_info &custom_type_info)
 This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually.
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gio::Resolverwrap (GResolver *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Detailed Description

Asynchronous and cancellable DNS resolver.

Resolver provides cancellable synchronous and asynchronous DNS resolution, for hostnames (lookup_by_address(), lookup_by_name() and their async variants) and SRV (service) records (lookup_service()).

NetworkAddress and NetworkService provide wrappers around Resolver functionality that also implement SocketConnectable, making it easy to connect to a remote host/service.

Since glibmm 2.24:

Member Enumeration Documentation

◆ NameLookupFlags

Enumerator
DEFAULT 

Default behavior (same as g_resolver_lookup_by_name()).

IPV4_ONLY 

Only resolve ipv4 addresses.

IPV6_ONLY 

Only resolve ipv6 addresses.

◆ RecordType

Enumerator
SRV 

Look up DNS SRV records for a domain.

MX 

Look up DNS MX records for a domain.

TXT 

Look up DNS TXT records for a name.

SOA 

Look up DNS SOA records for a zone.

NS 

Look up DNS NS records for a domain.

Constructor & Destructor Documentation

◆ Resolver()

Gio::Resolver::Resolver ( Resolver &&  src)
noexcept

◆ ~Resolver()

Gio::Resolver::~Resolver ( )
overridenoexcept

Member Function Documentation

◆ get_default()

static Glib::RefPtr< Resolver > Gio::Resolver::get_default ( )
static

◆ get_timeout()

unsigned Gio::Resolver::get_timeout ( ) const

Get the timeout applied to all resolver lookups.

See Resolver::property_timeout().

Since glibmm 2.78:
Returns
The resolver timeout, in milliseconds, or 0 for no timeout.

◆ get_type()

static GType Gio::Resolver::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GResolver * Gio::Resolver::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GResolver * Gio::Resolver::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GResolver * Gio::Resolver::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ lookup_by_address() [1/2]

Glib::ustring Gio::Resolver::lookup_by_address ( const Glib::RefPtr< InetAddress > &  address)

A lookup_by_address() convenience overload.

◆ lookup_by_address() [2/2]

Glib::ustring Gio::Resolver::lookup_by_address ( const Glib::RefPtr< InetAddress > &  address,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Synchronously reverse-resolves address to determine its associated hostname.

If the DNS resolution fails, error (if non-nullptr) will be set to a value from ResolverError.

If cancellable is non-nullptr, it can be used to cancel the operation, in which case error (if non-nullptr) will be set to Gio::Error::CANCELLED.

Since glibmm 2.22:
Parameters
addressThe address to reverse-resolve.
cancellableA Cancellable, or nullptr.
Returns
A hostname (either ASCII-only, or in ASCII-encoded form), or nullptr on error.
Exceptions
Glib::Error

◆ lookup_by_address_async() [1/2]

void Gio::Resolver::lookup_by_address_async ( const Glib::RefPtr< InetAddress > &  address,
const SlotAsyncReady &  slot 
)

Begins asynchronously reverse-resolving an address to determine its associated hostname, and eventually calls callback, which must call lookup_by_address_finish() to get the final result.

Parameters
addressThe address to reverse-resolve.
slotA callback slot to call after the resolution completes.

◆ lookup_by_address_async() [2/2]

void Gio::Resolver::lookup_by_address_async ( const Glib::RefPtr< InetAddress > &  address,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Begins asynchronously reverse-resolving an address to determine its associated hostname, and eventually calls callback, which must call lookup_by_address_finish() to get the final result.

Parameters
addressThe address to reverse-resolve.
slotA callback slot to call after the resolution completes.
cancellableA Cancellable object which can be used to cancel the operation.

◆ lookup_by_address_finish()

Glib::ustring Gio::Resolver::lookup_by_address_finish ( const Glib::RefPtr< AsyncResult > &  result)

Retrieves the result of a previous call to g_resolver_lookup_by_address_async().

If the DNS resolution failed, error (if non-nullptr) will be set to a value from ResolverError. If the operation was cancelled, error will be set to Gio::Error::CANCELLED.

Since glibmm 2.22:
Parameters
resultThe result passed to your SlotAsyncReady.
Returns
A hostname (either ASCII-only, or in ASCII-encoded form), or nullptr on error.
Exceptions
Glib::Error

◆ lookup_by_name() [1/2]

std::vector< Glib::RefPtr< InetAddress > > Gio::Resolver::lookup_by_name ( const Glib::ustring hostname)

A lookup_by_name() convenience overload.

◆ lookup_by_name() [2/2]

std::vector< Glib::RefPtr< InetAddress > > Gio::Resolver::lookup_by_name ( const Glib::ustring hostname,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Synchronously resolves hostname to determine its associated IP address(es).

hostname may be an ASCII-only or UTF-8 hostname, or the textual form of an IP address (in which case this just becomes a wrapper around g_inet_address_new_from_string()).

On success, g_resolver_lookup_by_name() will return a non-empty List of InetAddress, sorted in order of preference and guaranteed to not contain duplicates. That is, if using the result to connect to hostname, you should attempt to connect to the first address first, then the second if the first fails, etc. If you are using the result to listen on a socket, it is appropriate to add each result using e.g. g_socket_listener_add_address().

If the DNS resolution fails, error (if non-nullptr) will be set to a value from ResolverError and nullptr will be returned.

If cancellable is non-nullptr, it can be used to cancel the operation, in which case error (if non-nullptr) will be set to Gio::Error::CANCELLED.

If you are planning to connect to a socket on the resolved IP address, it may be easier to create a NetworkAddress and use its SocketConnectable interface.

Since glibmm 2.22:
Parameters
hostnameThe hostname to look up.
cancellableA Cancellable, or nullptr.
Returns
A non-empty List of InetAddress, or nullptr on error. You must unref each of the addresses and free the list when you are done with it. (You can use g_resolver_free_addresses() to do this.).
Exceptions
Glib::Error

◆ lookup_by_name_async() [1/2]

void Gio::Resolver::lookup_by_name_async ( const Glib::ustring hostname,
const SlotAsyncReady &  slot 
)

Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls slot, which must call lookup_by_name_finish() to get the result.

See lookup_by_name() for more details.

Parameters
hostnameThe hostname to look up.
slotA callback slot to call after the resolution completes.

◆ lookup_by_name_async() [2/2]

void Gio::Resolver::lookup_by_name_async ( const Glib::ustring hostname,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls slot, which must call lookup_by_name_finish() to get the result.

See lookup_by_name() for more details.

Parameters
hostnameThe hostname to look up.
slotA callback slot to call after the resolution completes.
cancellableA Cancellable object which can be used to cancel the operation.

◆ lookup_by_name_finish()

std::vector< Glib::RefPtr< InetAddress > > Gio::Resolver::lookup_by_name_finish ( const Glib::RefPtr< AsyncResult > &  result)

Retrieves the result of a call to g_resolver_lookup_by_name_async().

If the DNS resolution failed, error (if non-nullptr) will be set to a value from ResolverError. If the operation was cancelled, error will be set to Gio::Error::CANCELLED.

Since glibmm 2.22:
Parameters
resultThe result passed to your SlotAsyncReady.
Returns
A List of InetAddress, or nullptr on error. See g_resolver_lookup_by_name() for more details.
Exceptions
Glib::Error

◆ lookup_by_name_with_flags()

std::vector< Glib::RefPtr< InetAddress > > Gio::Resolver::lookup_by_name_with_flags ( const Glib::ustring hostname,
NameLookupFlags  flags,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)

This differs from g_resolver_lookup_by_name() in that you can modify the lookup behavior with flags.

For example this can be used to limit results with Gio::Resolver::NameLookupFlags::IPV4_ONLY.

Since glibmm 2.74:
Parameters
hostnameThe hostname to look up.
flagsExtra ResolverNameLookupFlags for the lookup.
cancellableA Cancellable, or nullptr.
Returns
A non-empty List of InetAddress, or nullptr on error. You must unref each of the addresses and free the list when you are done with it. (You can use g_resolver_free_addresses() to do this.).
Exceptions
Glib::Error

◆ lookup_by_name_with_flags_async()

void Gio::Resolver::lookup_by_name_with_flags_async ( const Glib::ustring hostname,
NameLookupFlags  flags,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)

Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls slot, which must call g_resolver_lookup_by_name_with_flags_finish() to get the result.

See g_resolver_lookup_by_name() for more details.

Since glibmm 2.74:
Parameters
hostnameThe hostname to look up the address of.
flagsExtra ResolverNameLookupFlags for the lookup.
cancellableA Cancellable, or nullptr.
slotCallback to call after resolution completes.

◆ lookup_by_name_with_flags_finish()

std::vector< Glib::RefPtr< InetAddress > > Gio::Resolver::lookup_by_name_with_flags_finish ( const Glib::RefPtr< AsyncResult > &  result)

Retrieves the result of a call to g_resolver_lookup_by_name_with_flags_async().

If the DNS resolution failed, error (if non-nullptr) will be set to a value from ResolverError. If the operation was cancelled, error will be set to Gio::Error::CANCELLED.

Since glibmm 2.74:
Parameters
resultThe result passed to your SlotAsyncReady.
Returns
A List of InetAddress, or nullptr on error. See g_resolver_lookup_by_name() for more details.
Exceptions
Glib::Error

◆ lookup_records() [1/2]

std::vector< Glib::VariantContainerBase > Gio::Resolver::lookup_records ( const Glib::ustring rrname,
RecordType  record_type 
)

A lookup_records() convenience overload.

◆ lookup_records() [2/2]

std::vector< Glib::VariantContainerBase > Gio::Resolver::lookup_records ( const Glib::ustring rrname,
RecordType  record_type,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Synchronously performs a DNS record lookup for the given rrname and returns a list of records as Variant tuples.

See Gio::Resolver::RecordType for information on what the records contain for each record_type.

If the DNS resolution fails, error (if non-nullptr) will be set to a value from ResolverError and nullptr will be returned.

If cancellable is non-nullptr, it can be used to cancel the operation, in which case error (if non-nullptr) will be set to Gio::Error::CANCELLED.

Since glibmm 2.34:
Parameters
rrnameThe DNS name to look up the record for.
record_typeThe type of DNS record to look up.
cancellableA Cancellable, or nullptr.
Returns
A non-empty List of Variant, or nullptr on error. You must free each of the records and the list when you are done with it. (You can use Glib::list_free_full() with Glib::variant_unref() to do this.).
Exceptions
Glib::Error

◆ lookup_records_async() [1/2]

void Gio::Resolver::lookup_records_async ( const Glib::ustring rrname,
RecordType  record_type,
const SlotAsyncReady &  slot 
)

A non-cancellable version of lookup_records_async().

◆ lookup_records_async() [2/2]

void Gio::Resolver::lookup_records_async ( const Glib::ustring rrname,
RecordType  record_type,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Begins asynchronously performing a DNS lookup for the given rrname, and eventually calls slot, which must call lookup_records_finish() to get the final result.

See lookup_records() for more details.

Parameters
rrnameThe DNS name to lookup the record for.
record_typeThe type of DNS record to lookup.
cancellableA Cancellable.
slotThe slot to call after the resolution completes.
Since glibmm 2.36:

◆ lookup_records_finish()

std::vector< Glib::VariantContainerBase > Gio::Resolver::lookup_records_finish ( const Glib::RefPtr< AsyncResult > &  result)

Retrieves the result of a previous call to g_resolver_lookup_records_async().

Returns a non-empty list of records as Variant tuples. See Gio::Resolver::RecordType for information on what the records contain.

If the DNS resolution failed, error (if non-nullptr) will be set to a value from ResolverError. If the operation was cancelled, error will be set to Gio::Error::CANCELLED.

Since glibmm 2.34:
Parameters
resultThe result passed to your SlotAsyncReady.
Returns
A non-empty List of Variant, or nullptr on error. You must free each of the records and the list when you are done with it. (You can use Glib::list_free_full() with Glib::variant_unref() to do this.).
Exceptions
Glib::Error

◆ lookup_service() [1/2]

std::vector< SrvTarget > Gio::Resolver::lookup_service ( const Glib::ustring service,
const Glib::ustring protocol,
const Glib::ustring domain 
)

A lookup_service() convenience overload.

◆ lookup_service() [2/2]

std::vector< SrvTarget > Gio::Resolver::lookup_service ( const Glib::ustring service,
const Glib::ustring protocol,
const Glib::ustring domain,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of SrvTarget.

domain may be an ASCII-only or UTF-8 hostname. Note also that the service and protocol arguments do not include the leading underscore that appears in the actual DNS entry.

On success, g_resolver_lookup_service() will return a non-empty List of SrvTarget, sorted in order of preference. (That is, you should attempt to connect to the first target first, then the second if the first fails, etc.)

If the DNS resolution fails, error (if non-nullptr) will be set to a value from ResolverError and nullptr will be returned.

If cancellable is non-nullptr, it can be used to cancel the operation, in which case error (if non-nullptr) will be set to Gio::Error::CANCELLED.

If you are planning to connect to the service, it is usually easier to create a NetworkService and use its SocketConnectable interface.

Since glibmm 2.22:
Parameters
serviceThe service type to look up (eg, "ldap").
protocolThe networking protocol to use for service (eg, "tcp").
domainThe DNS domain to look up the service in.
cancellableA Cancellable, or nullptr.
Returns
A non-empty List of SrvTarget, or nullptr on error. You must free each of the targets and the list when you are done with it. (You can use g_resolver_free_targets() to do this.).
Exceptions
Glib::Error

◆ lookup_service_async() [1/2]

void Gio::Resolver::lookup_service_async ( const Glib::ustring service,
const Glib::ustring protocol,
const Glib::ustring domain,
const SlotAsyncReady &  slot 
)

Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, which must call lookup_service_finish() to get the final result.

See glookup_service() for more details.

Parameters
serviceThe service type to look up (eg, "ldap").
protocolThe networking protocol to use for service (eg, "tcp")
domainThe DNS domain to look up the service in.
slotA callback slot to call after the resolution completes.

◆ lookup_service_async() [2/2]

void Gio::Resolver::lookup_service_async ( const Glib::ustring service,
const Glib::ustring protocol,
const Glib::ustring domain,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable 
)

Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, which must call lookup_service_finish() to get the final result.

See glookup_service() for more details.

Parameters
serviceThe service type to look up (eg, "ldap").
protocolThe networking protocol to use for service (eg, "tcp")
domainThe DNS domain to look up the service in.
slotA callback slot to call after the resolution completes.
cancellableA Cancellable object which can be used to cancel the operation.

◆ lookup_service_finish()

std::vector< SrvTarget > Gio::Resolver::lookup_service_finish ( const Glib::RefPtr< AsyncResult > &  result)

Retrieves the result of a previous call to g_resolver_lookup_service_async().

If the DNS resolution failed, error (if non-nullptr) will be set to a value from ResolverError. If the operation was cancelled, error will be set to Gio::Error::CANCELLED.

Since glibmm 2.22:
Parameters
resultThe result passed to your SlotAsyncReady.
Returns
A non-empty List of SrvTarget, or nullptr on error. See g_resolver_lookup_service() for more details.
Exceptions
Glib::Error

◆ on_reload()

virtual void Gio::Resolver::on_reload ( )
protectedvirtual

This is a default handler for the signal signal_reload().

◆ operator=()

Resolver & Gio::Resolver::operator= ( Resolver &&  src)
noexcept

◆ property_timeout() [1/2]

Glib::PropertyProxy< unsigned int > Gio::Resolver::property_timeout ( )

The timeout applied to all resolver lookups, in milliseconds.

This may be changed through the lifetime of the Resolver. The new value will apply to any lookups started after the change, but not to any already-ongoing lookups.

If this is 0, no timeout is applied to lookups.

No timeout was applied to lookups before this property was added in GLib 2.78.

Since glibmm 2.78:

Default value: 0

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_timeout() [2/2]

Glib::PropertyProxy_ReadOnly< unsigned int > Gio::Resolver::property_timeout ( ) const

The timeout applied to all resolver lookups, in milliseconds.

This may be changed through the lifetime of the Resolver. The new value will apply to any lookups started after the change, but not to any already-ongoing lookups.

If this is 0, no timeout is applied to lookups.

No timeout was applied to lookups before this property was added in GLib 2.78.

Since glibmm 2.78:

Default value: 0

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_default()

static void Gio::Resolver::set_default ( const Glib::RefPtr< Resolver > &  resolver)
static

◆ set_timeout()

void Gio::Resolver::set_timeout ( unsigned  timeout_ms)

Set the timeout applied to all resolver lookups.

See Resolver::property_timeout().

Since glibmm 2.78:
Parameters
timeout_msTimeout in milliseconds, or 0 for no timeouts.

◆ signal_reload()

Glib::SignalProxy< void()> Gio::Resolver::signal_reload ( )
Slot Prototype:
void on_my_reload()

Flags: Run Last

Emitted when the resolver notices that the system resolver configuration has changed.

Friends And Related Symbol Documentation

◆ wrap()

Glib::RefPtr< Gio::Resolver > wrap ( GResolver object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.