Gio.SocketClient.prototype.connect_to_uri
function connect_to_uri(uri: String, default_port: Number(guint16), cancellable: Gio.Cancellable): Gio.SocketConnection { // Gjs wrapper for g_socket_client_connect_to_uri() }
This is a helper function for Gio.SocketClient.prototype.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 Gio.SocketClient.tls is true. (Gio.SocketClient does not know to automatically assume TLS for certain URI schemes.)
Using this rather than Gio.SocketClient.prototype.connect or Gio.SocketClient.prototype.connect_to_host 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.
Since 2.26
- uri
A network URI
- default_port
the default port to connect to
- cancellable
a Gio.Cancellable, or null
- Returns
a Gio.SocketConnection on success, null on error.