Gio.Resolver.lookup_service

### Method

# Gio Resolverlookup_service

since: 2.22

#### Declaration [src]

    GList*
    g_resolver_lookup_service (
      GResolver* resolver,
      const gchar* service,
      const gchar* protocol,
      const gchar* domain,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

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 method.
  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 method.
  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 method.
  The value is a NUL terminated UTF-8 string.

`cancellable`

  Type: `GCancellable`

  A `GCancellable`, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`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 a `NULL` `GError*`.
  The argument will be 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.

#### Return value

Type: A list of `None`

A non-empty `GList` of `GSrvTarget`, or `NULL` 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.).

The caller of the method takes ownership of the returned data, and is responsible for freeing it.