Class: Gio::Resolver
- Inherits:
-
Object
- Object
- Gio::Resolver
- Defined in:
- (unknown)
Direct Known Subclasses
Class Method Summary collapse
-
.default ⇒ Gio::Resolver
Gets the default #GResolver.
-
.free_addresses(addresses) ⇒ nil
Frees addresses (which should be the return value from g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()).
-
.free_targets(targets) ⇒ nil
Frees targets (which should be the return value from g_resolver_lookup_service() or g_resolver_lookup_service_finish()).
Instance Method Summary collapse
-
#lookup_by_address(address, cancellable) ⇒ String
Synchronously reverse-resolves address to determine its associated hostname.
-
#lookup_by_address_async(address, cancellable, callback, user_data) ⇒ nil
Begins asynchronously reverse-resolving address to determine its associated hostname, and eventually calls callback, which must call g_resolver_lookup_by_address_finish() to get the final result.
-
#lookup_by_address_finish(result) ⇒ String
Retrieves the result of a previous call to g_resolver_lookup_by_address_async().
-
#lookup_by_name(hostname, cancellable) ⇒ GLib::List<Gio::InetAddress>
Synchronously resolves hostname to determine its associated IP address(es).
-
#lookup_by_name_async(hostname, cancellable, callback, user_data) ⇒ nil
Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls callback, which must call g_resolver_lookup_by_name_finish() to get the result.
-
#lookup_by_name_finish(result) ⇒ GLib::List<Gio::InetAddress>
Retrieves the result of a call to g_resolver_lookup_by_name_async().
-
#lookup_by_name_with_flags(hostname, flags, cancellable) ⇒ GLib::List<Gio::InetAddress>
This differs from g_resolver_lookup_by_name() in that you can modify the lookup behavior with flags.
-
#lookup_by_name_with_flags_async(hostname, flags, cancellable, callback, user_data) ⇒ nil
Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls callback, which must call g_resolver_lookup_by_name_with_flags_finish() to get the result.
-
#lookup_by_name_with_flags_finish(result) ⇒ GLib::List<Gio::InetAddress>
Retrieves the result of a call to g_resolver_lookup_by_name_with_flags_async().
-
#lookup_records(rrname, record_type, cancellable) ⇒ GLib::List<GLib::Variant>
Synchronously performs a DNS record lookup for the given rrname and returns a list of records as #GVariant tuples.
-
#lookup_records_async(rrname, record_type, cancellable, callback, user_data) ⇒ nil
Begins asynchronously performing a DNS lookup for the given rrname, and eventually calls callback, which must call g_resolver_lookup_records_finish() to get the final result.
-
#lookup_records_finish(result) ⇒ GLib::List<GLib::Variant>
Retrieves the result of a previous call to g_resolver_lookup_records_async().
-
#lookup_service(service, protocol, domain, cancellable) ⇒ GLib::List<Gio::SrvTarget>
Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of GSrv::Target.
-
#lookup_service_async(service, protocol, domain, cancellable, callback, user_data) ⇒ nil
Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, which must call g_resolver_lookup_service_finish() to get the final result.
-
#lookup_service_finish(result) ⇒ GLib::List<Gio::SrvTarget>
Retrieves the result of a previous call to g_resolver_lookup_service_async().
-
#set_default ⇒ nil
Sets resolver to be the application's default resolver (reffing resolver, and unreffing the previous default resolver, if any).
-
#timeout ⇒ Integer
The timeout applied to all resolver lookups, in milliseconds.
-
#timeout=(timeout) ⇒ Integer
The timeout applied to all resolver lookups, in milliseconds.
Class Method Details
.default ⇒ Gio::Resolver
Gets the default #GResolver. You should unref it when you are done
with it. #GResolver may use its reference count as a hint about how
many threads it should allocate for concurrent DNS resolutions.
.free_addresses(addresses) ⇒ nil
Frees addresses (which should be the return value from
g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()).
(This is a convenience method; you can also simply free the results
by hand.)
.free_targets(targets) ⇒ nil
Frees targets (which should be the return value from
g_resolver_lookup_service() or g_resolver_lookup_service_finish()).
(This is a convenience method; you can also simply free the
results by hand.)
Instance Method Details
#lookup_by_address(address, cancellable) ⇒ String
Synchronously reverse-resolves address to determine its
associated hostname.
If the DNS resolution fails, error (if non-nil) will be set to
a value from GResolver::Error.
If cancellable is non-nil, it can be used to cancel the
operation, in which case error (if non-nil) will be set to
%G_IO_ERROR_CANCELLED.
#lookup_by_address_async(address, cancellable, callback, user_data) ⇒ nil
Begins asynchronously reverse-resolving address to determine its
associated hostname, and eventually calls callback, which must
call g_resolver_lookup_by_address_finish() to get the final result.
#lookup_by_address_finish(result) ⇒ String
Retrieves the result of a previous call to
g_resolver_lookup_by_address_async().
If the DNS resolution failed, error (if non-nil) will be set to
a value from GResolver::Error. If the operation was cancelled,
error will be set to %G_IO_ERROR_CANCELLED.
form), or nil on error.
#lookup_by_name(hostname, cancellable) ⇒ GLib::List<Gio::InetAddress>
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 #GList of
GInet::Address, 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-nil) will be set to a
value from GResolver::Error and nil will be returned.
If cancellable is non-nil, it can be used to cancel the
operation, in which case error (if non-nil) will be set to
%G_IO_ERROR_CANCELLED.
If you are planning to connect to a socket on the resolved IP
address, it may be easier to create a GNetwork::Address and use its
GSocket::Connectable interface.
of GInet::Address, or nil 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.)
#lookup_by_name_async(hostname, cancellable, callback, user_data) ⇒ nil
Begins asynchronously resolving hostname to determine its
associated IP address(es), and eventually calls callback, which
must call g_resolver_lookup_by_name_finish() to get the result.
See g_resolver_lookup_by_name() for more details.
#lookup_by_name_finish(result) ⇒ GLib::List<Gio::InetAddress>
Retrieves the result of a call to
g_resolver_lookup_by_name_async().
If the DNS resolution failed, error (if non-nil) will be set to
a value from GResolver::Error. If the operation was cancelled,
error will be set to %G_IO_ERROR_CANCELLED.
of GInet::Address, or nil on error. See g_resolver_lookup_by_name()
for more details.
#lookup_by_name_with_flags(hostname, flags, cancellable) ⇒ GLib::List<Gio::InetAddress>
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 %G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY.
of GInet::Address, or nil 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.)
#lookup_by_name_with_flags_async(hostname, flags, cancellable, callback, user_data) ⇒ nil
Begins asynchronously resolving hostname to determine its
associated IP address(es), and eventually calls callback, which
must call g_resolver_lookup_by_name_with_flags_finish() to get the result.
See g_resolver_lookup_by_name() for more details.
#lookup_by_name_with_flags_finish(result) ⇒ GLib::List<Gio::InetAddress>
Retrieves the result of a call to
g_resolver_lookup_by_name_with_flags_async().
If the DNS resolution failed, error (if non-nil) will be set to
a value from GResolver::Error. If the operation was cancelled,
error will be set to %G_IO_ERROR_CANCELLED.
of GInet::Address, or nil on error. See g_resolver_lookup_by_name()
for more details.
#lookup_records(rrname, record_type, cancellable) ⇒ GLib::List<GLib::Variant>
Synchronously performs a DNS record lookup for the given rrname and returns
a list of records as #GVariant tuples. See GResolver::RecordType for
information on what the records contain for each record_type.
If the DNS resolution fails, error (if non-nil) will be set to
a value from GResolver::Error and nil will be returned.
If cancellable is non-nil, it can be used to cancel the
operation, in which case error (if non-nil) will be set to
%G_IO_ERROR_CANCELLED.
#GVariant, or nil on error. You must free each of the records and the list
when you are done with it. (You can use g_list_free_full() with
g_variant_unref() to do this.)
#lookup_records_async(rrname, record_type, cancellable, callback, user_data) ⇒ nil
Begins asynchronously performing a DNS lookup for the given
rrname, and eventually calls callback, which must call
g_resolver_lookup_records_finish() to get the final result. See
g_resolver_lookup_records() for more details.
#lookup_records_finish(result) ⇒ GLib::List<GLib::Variant>
Retrieves the result of a previous call to
g_resolver_lookup_records_async(). Returns a non-empty list of records as
#GVariant tuples. See GResolver::RecordType for information on what the
records contain.
If the DNS resolution failed, error (if non-nil) will be set to
a value from GResolver::Error. If the operation was cancelled,
error will be set to %G_IO_ERROR_CANCELLED.
#GVariant, or nil on error. You must free each of the records and the list
when you are done with it. (You can use g_list_free_full() with
g_variant_unref() to do this.)
#lookup_service(service, protocol, domain, cancellable) ⇒ GLib::List<Gio::SrvTarget>
Synchronously performs a DNS SRV lookup for the given service and
protocol in the given domain and returns an array of GSrv::Target.
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 #GList of
GSrv::Target, 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-nil) will be set to
a value from GResolver::Error and nil will be returned.
If cancellable is non-nil, it can be used to cancel the
operation, in which case error (if non-nil) will be set to
%G_IO_ERROR_CANCELLED.
If you are planning to connect to the service, it is usually easier
to create a GNetwork::Service and use its #GSocketConnectable
interface.
GSrv::Target, or nil 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.)
#lookup_service_async(service, protocol, domain, cancellable, callback, user_data) ⇒ nil
Begins asynchronously performing a DNS SRV lookup for the given
service and protocol in the given domain, and eventually calls
callback, which must call g_resolver_lookup_service_finish() to
get the final result. See g_resolver_lookup_service() for more
details.
#lookup_service_finish(result) ⇒ GLib::List<Gio::SrvTarget>
Retrieves the result of a previous call to
g_resolver_lookup_service_async().
If the DNS resolution failed, error (if non-nil) will be set to
a value from GResolver::Error. If the operation was cancelled,
error will be set to %G_IO_ERROR_CANCELLED.
GSrv::Target, or nil on error. See g_resolver_lookup_service() for more
details.
#set_default ⇒ nil
Sets resolver to be the application's default resolver (reffing
resolver, and unreffing the previous default resolver, if any).
Future calls to g_resolver_get_default() will return this resolver.
This can be used if an application wants to perform any sort of DNS
caching or "pinning"; it can implement its own #GResolver that
calls the original default resolver for DNS operations, and
implements its own cache policies on top of that, and then set
itself as the default resolver for all later code to use.
#timeout ⇒ Integer
The timeout applied to all resolver lookups, in milliseconds.
This may be changed through the lifetime of the #GResolver. 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.
#timeout=(timeout) ⇒ Integer
The timeout applied to all resolver lookups, in milliseconds.
This may be changed through the lifetime of the #GResolver. 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.