Gio.Resolver::lookup_by_name
function vfunc_lookup_by_name(hostname: String, cancellable: Gio.Cancellable): Array(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 Gio.InetAddress.new_from_string).
On success, Gio.Resolver.prototype.lookup_by_name will return a GLib.List of Gio.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. Gio.SocketListener.prototype.add_address.
If the DNS resolution fails, @error (if non-null) will be set to a value from Gio.ResolverError.
If cancellable is non-null, it can be used to cancel the operation, in which case @error (if non-null) will be set to Gio.IOErrorEnum.cancelled.
If you are planning to connect to a socket on the resolved IP address, it may be easier to create a Gio.NetworkAddress and use its Gio.SocketConnectable interface.
Since 2.22
- hostname
the hostname to look up
- cancellable
a Gio.Cancellable, or null
- Returns
a GLib.List of Gio.InetAddress, or null on error. You must unref each of the addresses and free the list when you are done with it. (You can use Gio.Resolver.free_addresses to do this.)