Gio.Socket.prototype.connect
function connect(address: Gio.SocketAddress, cancellable: Gio.Cancellable): Boolean { // Gjs wrapper for g_socket_connect() }
Connect the socket to the specified remote address.
For connection oriented socket this generally means we attempt to make a connection to the address. For a connection-less socket it sets the default address for Gio.Socket.prototype.send and discards all incoming datagrams from other sources.
Generally connection oriented sockets can only connect once, but connection-less sockets can connect multiple times to change the default address.
If the connect call needs to do network I/O it will block, unless non-blocking I/O is enabled. Then Gio.IOErrorEnum.pending is returned and the user can be notified of the connection finishing by waiting for the G_IO_OUT condition. The result of the connection must then be checked with Gio.Socket.prototype.check_connect_result.
Since 2.22
- address
a Gio.SocketAddress specifying the remote address.
- cancellable
a %GCancellable or null
- Returns
true if connected, false on error.