Method

GioSocketClientconnect_to_service

Declaration [src]

GSocketConnection*
g_socket_client_connect_to_service (
  GSocketClient* client,
  const gchar* domain,
  const gchar* service,
  GCancellable* cancellable,
  GError** error
)

Description [src]

Attempts to create a TCP connection to a service.

This call looks up the SRV record for service at domain for the “tcp” protocol. It then attempts to connect, in turn, to each of the hosts providing the service until either a connection succeeds or there are no hosts remaining.

Upon a successful connection, a new GSocketConnection is constructed and returned. The caller owns this new object and must drop their reference to it when finished with it.

In the event of any failure (DNS error, service not found, no hosts connectable) NULL is returned and error (if non-NULL) is set accordingly.

Parameters

domain

Type: const gchar*

A domain name.

The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.
service

Type: const gchar*

The name of the service to connect to.

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: GSocketConnection

A GSocketConnection if successful, or NULL on error.

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