SocketClient.connect

Tries to resolve the connectable and make a network connection to it.

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.

The type of the #GSocketConnection object returned depends on the type of the underlying socket that is used. For instance, for a TCP/IP connection it will be a #GTcpConnection.

The socket created will be the same family as the address that the connectable resolves to, unless family is set with [gio.socket_client.SocketClient.setFamily] or indirectly via [gio.socket_client.SocketClient.setLocalAddress]. The socket type defaults to [gio.types.SocketType.Stream] but can be set with [gio.socket_client.SocketClient.setSocketType].

If a local address is specified with [gio.socket_client.SocketClient.setLocalAddress] the socket will be bound to this address before connecting.

Parameters

connectablea #GSocketConnectable specifying the remote address.
cancellableoptional #GCancellable object, null to ignore.

Returns

a #GSocketConnection on success, null on error.

Throws

[ErrorWrap]