SocketClient.connectToUri

This is a helper function for g_socket_client_connect().

Attempts to create a TCP connection with a network URI.

@uri may be any valid URI containing an "authority" (hostname/port) component. If a port is not specified in the URI, @default_port will be used. TLS will be negotiated if #GSocketClient:tls is %TRUE. (#GSocketClient does not know to automatically assume TLS for certain URI schemes.)

Using this rather than g_socket_client_connect() or g_socket_client_connect_to_host() allows #GSocketClient to determine when to use application-specific proxy protocols.

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.

class SocketClient
connectToUri

Parameters

uri string

A network URI

defaultPort ushort

the default port to connect to

cancellable Cancellable

a #GCancellable, or %NULL

Return: a #GSocketConnection on success, %NULL on error.

Throws

GException on failure.

Meta

Since

2.26