Gio.SocketClient.prototype.connect
function connect(connectable: Gio.SocketConnectable, cancellable: Gio.Cancellable): Gio.SocketConnection { // Gjs wrapper for g_socket_client_connect() }
Tries to resolve the connectable and make a network connection to it.
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.
The type of the Gio.SocketConnection object returned depends on the type of the underlying socket that is used. For instance, for a TCP/IP connection it will be a Gio.TcpConnection.
The socket created will be the same family as the address that the connectable resolves to, unless family is set with Gio.SocketClient.prototype.set_family or indirectly via Gio.SocketClient.prototype.set_local_address. The socket type defaults to Gio.SocketType.stream but can be set with Gio.SocketClient.prototype.set_socket_type.
If a local address is specified with Gio.SocketClient.prototype.set_local_address the socket will be bound to this address before connecting.
Since 2.22
- connectable
a Gio.SocketConnectable specifying the remote address.
- cancellable
optional Gio.Cancellable object, null to ignore.
- Returns
a Gio.SocketConnection on success, null on error.