glibmm: Gio::Resolver Class Reference

# Gio::Resolver Class Reference
[Portable Network I/O Functionality]

Asynchronous and cancellable DNS resolver. More...

`#include <giomm/resolver.h>`

Inheritance diagram for Gio::Resolver:
[legend]

List of all members.

## Public Member Functions

virtual | ~Resolver ()
GResolver* | gobj ()
| Provides access to the underlying C GObject.
const GResolver* | gobj () const
| Provides access to the underlying C GObject.
GResolver* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::ListHandle< 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).
Glib::ListHandle< Glib::RefPtr < InetAddress > > | lookup_by_name (const Glib::ustring& hostname)
void | lookup_by_name_async (const Glib::ustring& hostname, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
void | lookup_by_name_async (const Glib::ustring& hostname, const SlotAsyncReady& slot)
Glib::ListHandle< 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().
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)
void | lookup_by_address_async (const Glib::RefPtr< InetAddress >& address, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
void | lookup_by_address_async (const Glib::RefPtr< InetAddress >& address, const SlotAsyncReady& slot)
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().
ListHandle_SrvTarget | 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.
ListHandle_SrvTarget | lookup_service (const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain)
void | lookup_service_async (const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
void | lookup_service_async (const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const SlotAsyncReady& slot)
ListHandle_SrvTarget | lookup_service_finish (const Glib::RefPtr< AsyncResult >& result)
| Retrieves the result of a previous call to g_resolver_lookup_service_async().
Glib::SignalProxy0< void > | signal_reload ()

## Static Public Member Functions

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

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::Resolver > | wrap (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:

## Constructor & Destructor Documentation

virtual Gio::Resolver::~Resolver | ( |  | ) | `[virtual]`

## Member Function Documentation

static Glib::RefPtr<Resolver> Gio::Resolver::get_default | ( |  | ) | `[static]`

const GResolver* Gio::Resolver::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GResolver* Gio::Resolver::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

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.

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

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-`0`) will be set to a value from ResolverError.

If cancellable is non-`0`, it can be used to cancel the operation, in which case error (if non-`0`) will be set to IO_ERROR_CANCELLED.

Since glibmm 2.22:

Parameters:

  | address | The address to reverse-resolve.
  | cancellable | A Cancellable, or `0`.

Returns:
  A hostname (either ASCII-only, or in ASCII-encoded form), or `0` on error.

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

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

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-`0`) will be set to a value from ResolverError. If the operation was cancelled, error will be set to IO_ERROR_CANCELLED.

Since glibmm 2.22:

Parameters:

  | result | The result passed to your AsyncReadyCallback.

Returns:
  A hostname (either ASCII-only, or in ASCII-encoded form), or `0` on error.

Glib::ListHandle< Glib::RefPtr<InetAddress> > Gio::Resolver::lookup_by_name | ( | const Glib::ustring& | hostname | ) |

Glib::ListHandle< 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 List of InetAddress, sorted in order of preference. (That is, you should attempt to connect to the first address first, then the second if the first fails, etc.)

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

If cancellable is non-`0`, it can be used to cancel the operation, in which case error (if non-`0`) will be set to IO_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:

  | hostname | The hostname to look up.
  | cancellable | A Cancellable, or `0`.

Returns:
  A List of InetAddress, or `0` 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.).

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

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

Glib::ListHandle< 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-`0`) will be set to a value from ResolverError. If the operation was cancelled, error will be set to IO_ERROR_CANCELLED.

Since glibmm 2.22:

Parameters:

  | result | The result passed to your AsyncReadyCallback.

Returns:
  A List of InetAddress, or `0` on error. See g_resolver_lookup_by_name() for more details.

ListHandle_SrvTarget Gio::Resolver::lookup_service | ( | const Glib::ustring& | service,
|  | const Glib::ustring& | protocol,
|  | const Glib::ustring& | domain |
| ) |  |  |

ListHandle_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 <emphasis>do not</emphasis> include the leading underscore that appears in the actual DNS entry.

On success, g_resolver_lookup_service() will return a 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-`0`) will be set to a value from ResolverError.

If cancellable is non-`0`, it can be used to cancel the operation, in which case error (if non-`0`) will be set to IO_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:

  | service | The service type to look up (eg, "ldap").
  | protocol | The networking protocol to use for service (eg, "tcp").
  | domain | The DNS domain to look up the service in.
  | cancellable | A Cancellable, or `0`.

Returns:
  A List of SrvTarget, or `0` 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.).

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

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 |
| ) |  |  |

ListHandle_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-`0`) will be set to a value from ResolverError. If the operation was cancelled, error will be set to IO_ERROR_CANCELLED.

Since glibmm 2.22:

Parameters:

  | result | The result passed to your AsyncReadyCallback.

Returns:
  A List of SrvTarget, or `0` on error. See g_resolver_lookup_service() for more details.

static void Gio::Resolver::set_default | ( | const Glib::RefPtr< Resolver >& | resolver | ) | `[static]`

Glib::SignalProxy0< void > Gio::Resolver::signal_reload | ( |  | ) |

Prototype:
  `void on_my_reload()`

## Friends And Related Function Documentation

Glib::RefPtr< Gio::Resolver > wrap | ( | GResolver * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

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

Parameters:

  | object | The C instance.
  | take_copy | False 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.