Class
GioSocketClient
since: 2.22
Description [src]
class Gio.SocketClient : GObject.Object
{
priv: GSocketClientPrivate*
}
GSocketClient
is a lightweight high-level utility class for connecting to
a network host using a connection oriented socket type.
You create a GSocketClient
object, set any options you want, and then
call a sync or async connect operation, which returns a
GSocketConnection
subclass on success.
The type of the GSocketConnection
object returned depends on the
type of the underlying socket that is in use. For instance, for a TCP/IP
connection it will be a GTcpConnection
.
As GSocketClient
is a lightweight object, you don’t need to cache it. You
can just create a new one any time you need one.
Available since: 2.22
Instance methods
g_socket_client_add_application_proxy
Enable proxy protocols to be handled by the application. When the
indicated proxy protocol is returned by the GProxyResolver
,
GSocketClient
will consider this protocol as supported but will
not try to find a GProxy
instance to handle handshaking. The
application must check for this case by calling
g_socket_connection_get_remote_address()
on the returned
GSocketConnection
, and seeing if it’s a GProxyAddress
of the
appropriate type, to determine whether or not it needs to handle
the proxy handshaking itself.
g_socket_client_connect
Tries to resolve the connectable
and make a network connection to it.
since: 2.22
g_socket_client_connect_async
This is the asynchronous version of g_socket_client_connect().
since: 2.22
g_socket_client_connect_finish
Finishes an async connect operation. See g_socket_client_connect_async().
since: 2.22
g_socket_client_connect_to_host
This is a helper function for g_socket_client_connect().
since: 2.22
g_socket_client_connect_to_host_async
This is the asynchronous version of g_socket_client_connect_to_host().
since: 2.22
g_socket_client_connect_to_host_finish
Finishes an async connect operation. See g_socket_client_connect_to_host_async().
since: 2.22
g_socket_client_connect_to_service_async
This is the asynchronous version of g_socket_client_connect_to_service().
since: 2.22
g_socket_client_connect_to_service_finish
Finishes an async connect operation. See g_socket_client_connect_to_service_async().
since: 2.22
g_socket_client_connect_to_uri_async
This is the asynchronous version of g_socket_client_connect_to_uri().
since: 2.26
g_socket_client_connect_to_uri_finish
Finishes an async connect operation. See g_socket_client_connect_to_uri_async().
since: 2.26
g_socket_client_get_enable_proxy
Gets the proxy enable state; see g_socket_client_set_enable_proxy().
since: 2.26
g_socket_client_get_proxy_resolver
Gets the GProxyResolver
being used by client
. Normally, this will
be the resolver returned by g_proxy_resolver_get_default(), but you
can override it with g_socket_client_set_proxy_resolver().
since: 2.36
g_socket_client_get_tls
Gets whether client
creates TLS connections. See
g_socket_client_set_tls()
for details.
since: 2.28
g_socket_client_get_tls_validation_flags
Gets the TLS validation flags used creating TLS connections via
client
.
deprecated: 2.72 since: 2.28
g_socket_client_set_enable_proxy
Sets whether or not client
attempts to make connections via a
proxy server. When enabled (the default), GSocketClient
will use a
GProxyResolver
to determine if a proxy protocol such as SOCKS is
needed, and automatically do the necessary proxy negotiation.
since: 2.26
g_socket_client_set_family
Sets the socket family of the socket client.
If this is set to something other than G_SOCKET_FAMILY_INVALID
then the sockets created by this object will be of the specified family.
since: 2.22
g_socket_client_set_local_address
Sets the local address of the socket client.
The sockets created by this object will bound to the
specified address (if not NULL
) before connecting.
since: 2.22
g_socket_client_set_protocol
Sets the protocol of the socket client. The sockets created by this object will use of the specified protocol.
since: 2.22
g_socket_client_set_proxy_resolver
Overrides the GProxyResolver
used by client
. You can call this if
you want to use specific proxies, rather than using the system
default proxy settings.
since: 2.36
g_socket_client_set_socket_type
Sets the socket type of the socket client. The sockets created by this object will be of the specified type.
since: 2.22
g_socket_client_set_timeout
Sets the I/O timeout for sockets created by client
. timeout
is a
time in seconds, or 0 for no timeout (the default).
since: 2.26
g_socket_client_set_tls
Sets whether client
creates TLS (aka SSL) connections. If tls
is
TRUE
, client
will wrap its connections in a GTlsClientConnection
and perform a TLS handshake when connecting.
since: 2.28
g_socket_client_set_tls_validation_flags
Sets the TLS validation flags used when creating TLS connections
via client
. The default value is G_TLS_CERTIFICATE_VALIDATE_ALL
.
deprecated: 2.72 since: 2.28
Properties
Gio.SocketClient:protocol
The protocol to use for socket construction, or 0
for default.
since: 2.22
Gio.SocketClient:tls-validation-flags
The TLS validation flags used when creating TLS connections. The
default value is G_TLS_CERTIFICATE_VALIDATE_ALL
.
deprecated: 2.72
Signals
Gio.SocketClient::event
Emitted when client
‘s activity on connectable
changes state.
Among other things, this can be used to provide progress
information about a network connection in the UI. The meanings of
the different event
values are as follows:.
since: 2.32
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.
Class structure
struct GioSocketClientClass {
GObjectClass parent_class;
void (* event) (
GSocketClient* client,
GSocketClientEvent event,
GSocketConnectable* connectable,
GIOStream* connection
);
void (* _g_reserved1) (
void
);
void (* _g_reserved2) (
void
);
void (* _g_reserved3) (
void
);
void (* _g_reserved4) (
void
);
}
No description available.
Class members
parent_class: GObjectClass
No description available.
event: void (* event) ( GSocketClient* client, GSocketClientEvent event, GSocketConnectable* connectable, GIOStream* connection )
No description available.
_g_reserved1: void (* _g_reserved1) ( void )
No description available.
_g_reserved2: void (* _g_reserved2) ( void )
No description available.
_g_reserved3: void (* _g_reserved3) ( void )
No description available.
_g_reserved4: void (* _g_reserved4) ( void )
No description available.