class Gio::Resolver
- Gio::Resolver
- GObject::Object
- Reference
- Object
Overview
#GResolver provides cancellable synchronous and asynchronous DNS resolution, for hostnames (g_resolver_lookup_by_address(), g_resolver_lookup_by_name() and their async variants) and SRV (service) records (g_resolver_lookup_service()).
#GNetworkAddress and #GNetworkService provide wrappers around #GResolver functionality that also implement #GSocketConnectable, making it easy to connect to a remote host/service.
Defined in:
lib/gi-crystal/src/auto/gio-2.0/resolver.crConstructors
Class Method Summary
-
.default : Gio::Resolver
Gets the default #GResolver.
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#hash(hasher)
See
Object#hash(hasher)
-
#lookup_by_address(address : Gio::InetAddress, cancellable : Gio::Cancellable | Nil) : String
Synchronously reverse-resolves address to determine its associated hostname.
-
#lookup_by_address_async(address : Gio::InetAddress, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : 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 : Gio::AsyncResult) : String
Retrieves the result of a previous call to g_resolver_lookup_by_address_async().
-
#lookup_by_name(hostname : String, cancellable : Gio::Cancellable | Nil) : GLib::List
Synchronously resolves hostname to determine its associated IP address(es).
-
#lookup_by_name_async(hostname : String, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : 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 : Gio::AsyncResult) : GLib::List
Retrieves the result of a call to g_resolver_lookup_by_name_async().
-
#lookup_by_name_with_flags(hostname : String, flags : Gio::ResolverNameLookupFlags, cancellable : Gio::Cancellable | Nil) : GLib::List
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 : String, flags : Gio::ResolverNameLookupFlags, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : 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 : Gio::AsyncResult) : GLib::List
Retrieves the result of a call to g_resolver_lookup_by_name_with_flags_async().
-
#lookup_records(rrname : String, record_type : Gio::ResolverRecordType, cancellable : Gio::Cancellable | Nil) : GLib::List
Synchronously performs a DNS record lookup for the given rrname and returns a list of records as #GVariant tuples.
-
#lookup_records_async(rrname : String, record_type : Gio::ResolverRecordType, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : 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 : Gio::AsyncResult) : GLib::List
Retrieves the result of a previous call to g_resolver_lookup_records_async().
-
#lookup_service(service : String, protocol : String, domain : String, cancellable : Gio::Cancellable | Nil) : GLib::List
Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of #GSrvTarget.
-
#lookup_service_async(service : String, protocol : String, domain : String, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : 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 : Gio::AsyncResult) : GLib::List
Retrieves the result of a previous call to g_resolver_lookup_service_async().
- #reload_signal
-
#set_default : Nil
Sets resolver to be the application's default resolver (reffing resolver, and unreffing the previous default resolver, if any).
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
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.
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
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 #GResolverError.
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.
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.
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 #GResolverError. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED.
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 #GInetAddress, 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 #GResolverError 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 #GNetworkAddress and use its #GSocketConnectable interface.
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.
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 #GResolverError. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED.
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.
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.
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 #GResolverError. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED.
Synchronously performs a DNS record lookup for the given rrname and returns a list of records as #GVariant tuples. See #GResolverRecordType 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 #GResolverError 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.
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.
Retrieves the result of a previous call to g_resolver_lookup_records_async(). Returns a non-empty list of records as #GVariant tuples. See #GResolverRecordType for information on what the records contain.
If the DNS resolution failed, error (if non-nil
) will be set to
a value from #GResolverError. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED.
Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an array of #GSrvTarget. 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 #GSrvTarget, 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 #GResolverError 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 #GNetworkService and use its #GSocketConnectable interface.
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.
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 #GResolverError. If the operation was cancelled, error will be set to %G_IO_ERROR_CANCELLED.
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.