Resolver.lookupByName

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 GList of GInetAddress, 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-NULL) will be set to a value from GResolverError. If cancellable is non-NULL, it can be used to cancel the operation, in which case error (if non-NULL) 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. Since 2.22

class Resolver
lookupByName

Parameters

hostname string

the hostname to look up

cancellable Cancellable

a GCancellable, or NULL. [allow-none]

Return Value

Type: ListG

a GList of GInetAddress, or NULL 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.). [element-type GInetAddress][transfer full]

Throws

GException on failure.

Meta