SocketClient.connectToUri

This is a helper function for Socket.clientConnect.

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 tls is TRUE. (gio.SocketClient does not know to automatically assume TLS for certain URI schemes.)

Using this rather than Socket.clientConnect or Socket.clientConnectToHost allows gio.SocketClient to determine when to use application-specific proxy protocols.

Upon a successful connection, a new gio.SocketConnection 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 gio.Cancellable, or NULL

Return Value

a gio.SocketConnection on success, NULL on error.

Throws

GException on failure.

Meta

Since

2.26