Method
GioResolverlookup_service
since: 2.22
Declaration
GList*
g_resolver_lookup_service (
GResolver* resolver,
const gchar* service,
const gchar* protocol,
const gchar* domain,
GCancellable* cancellable,
GError** error
)
Description
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-NULL
) will be set to
a value from GResolverError
and NULL
will be returned.
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 the service, it is usually easier
to create a GNetworkService
and use its GSocketConnectable
interface.
Available since: 2.22
Parameters
service
-
Type:
const gchar*
The service type to look up (eg, “ldap”)
The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string. protocol
-
Type:
const gchar*
The networking protocol to use for
service
(eg, “tcp”)The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string. domain
-
Type:
const gchar*
The DNS domain to look up the service in.
The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string. cancellable
-
Type:
GCancellable
A
GCancellable
, orNULL
.The argument can be NULL
.The data is owned by the caller of the function. error
-
Type:
GError **
The return location for a recoverable error.
The argument can be NULL
.If the return location is not NULL
, then you must initialize it to aNULL
GError*
.The argument will left initialized to NULL
by the method if there are no errors.In case of error, the argument will be set to a newly allocated GError
; the caller will take ownership of the data, and be responsible for freeing it.