Method
GioSocketClientconnect_to_uri
since: 2.26
Declaration
GSocketConnection*
g_socket_client_connect_to_uri (
GSocketClient* client,
const gchar* uri,
guint16 default_port,
GCancellable* cancellable,
GError** error
)
Description
This is a helper function for g_socket_client_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 GSocketClient:tls is TRUE.
(GSocketClient does not know to automatically assume TLS for
certain URI schemes.)
Using this rather than g_socket_client_connect() or
g_socket_client_connect_to_host() allows GSocketClient to
determine when to use application-specific proxy protocols.
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.
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.
Available since: 2.26
Parameters
uri-
Type:
const gchar*A network URI.
The data is owned by the caller of the method. The value is a NUL terminated UTF-8 string. default_port-
Type:
guint16The default port to connect to.
cancellable-
Type:
GCancellableA
GCancellable, orNULL.The argument can be NULL.The data is owned by the caller of the method. error-
Type:
GError **The return location for a recoverable error.
The argument can be NULL.If the return location is not NULL, then you must initialize it to aNULLGError*.The argument will be left initialized to NULLby the method if there are no errors.In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.
Return value
Type: GSocketConnection
A GSocketConnection on success, NULL on error.
| The caller of the method takes ownership of the returned data, and is responsible for freeing it. |