SocketClient.connectToUri

This is a helper function for gio.socket_client.SocketClient.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 gio.socket_client.SocketClient.connect or gio.socket_client.SocketClient.connectToHost 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.

Parameters

uri string

A network URI

defaultPort ushort

the default port to connect to

cancellable gio.cancellable.Cancellable

a #GCancellable, or null

Return Value

Type: gio.socket_connection.SocketConnection

a #GSocketConnection on success, null on error.