connect_to_uri


Description:

[ Version ( since = "2.26" ) ]
public SocketConnection connect_to_uri (string uri, uint16 default_port, Cancellable? cancellable = null) throws Error

This is a helper function for 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 tls is true. (SocketClient does not know to automatically assume TLS for certain URI schemes.)

Using this rather than connect or connect_to_host allows SocketClient to determine when to use application-specific proxy protocols.

Upon a successful connection, a new 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 throws (if non-null) is set accordingly.

Parameters:

this

a SocketClient

uri

A network URI

default_port

the default port to connect to

cancellable

a Cancellable, or null

Returns:

a SocketConnection on success, null on error.