SocketClient

open class SocketClient(pointer: <Error class: unknown class><<Error class: unknown class>>)

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 class@Gio.SocketConnection subclass on success.

The type of the class@Gio.SocketConnection 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 class@Gio.TcpConnection.

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.

Skipped during bindings generation

  • method proxy-resolver: Property TypeInfo of getter and setter do not match

  • method type: Property has no getter nor setter

Since

2.22

Constructors

Link copied to clipboard
constructor()

Creates a new #GSocketClient with the default options.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Enable proxy support.

Link copied to clipboard

The address family to use for socket construction.

Link copied to clipboard
val gioSocketClientPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

The local address constructed sockets will be bound to.

Link copied to clipboard

The protocol to use for socket construction, or 0 for default.

Link copied to clipboard
open var timeout: <Error class: unknown class>

The I/O timeout for sockets, in seconds, or 0 for none.

Link copied to clipboard
open var tls: Boolean

Whether to create TLS connections.

Link copied to clipboard

The TLS validation flags used when creating TLS connections. The default value is %G_TLS_CERTIFICATE_VALIDATE_ALL.

Functions

Link copied to clipboard
open fun addApplicationProxy(protocol: String)

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.

Link copied to clipboard
open fun connect(connectable: SocketConnectable, cancellable: Cancellable? = null): <Error class: unknown class><SocketConnection>

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

Link copied to clipboard
open fun connectAsync(connectable: SocketConnectable, cancellable: Cancellable? = null, callback: AsyncReadyCallback?)

This is the asynchronous version of g_socket_client_connect().

Link copied to clipboard
fun connectEvent(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (event: SocketClientEvent, connectable: SocketConnectable, connection: IoStream?) -> Unit): <Error class: unknown class>

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:

Link copied to clipboard
open fun connectFinish(result: AsyncResult): <Error class: unknown class><SocketConnection>

Finishes an async connect operation. See g_socket_client_connect_async()

Link copied to clipboard
open fun connectToHost(hostAndPort: String, defaultPort: <Error class: unknown class>, cancellable: Cancellable? = null): <Error class: unknown class><SocketConnection>

This is a helper function for g_socket_client_connect().

Link copied to clipboard
open fun connectToHostAsync(hostAndPort: String, defaultPort: <Error class: unknown class>, cancellable: Cancellable? = null, callback: AsyncReadyCallback?)

This is the asynchronous version of g_socket_client_connect_to_host().

Link copied to clipboard
open fun connectToHostFinish(result: AsyncResult): <Error class: unknown class><SocketConnection>

Finishes an async connect operation. See g_socket_client_connect_to_host_async()

Link copied to clipboard
open fun connectToService(domain: String, service: String, cancellable: Cancellable? = null): <Error class: unknown class><SocketConnection>

Attempts to create a TCP connection to a service.

Link copied to clipboard
open fun connectToServiceAsync(domain: String, service: String, cancellable: Cancellable? = null, callback: AsyncReadyCallback?)

This is the asynchronous version of g_socket_client_connect_to_service().

Link copied to clipboard
open fun connectToServiceFinish(result: AsyncResult): <Error class: unknown class><SocketConnection>

Finishes an async connect operation. See g_socket_client_connect_to_service_async()

Link copied to clipboard
open fun connectToUri(uri: String, defaultPort: <Error class: unknown class>, cancellable: Cancellable? = null): <Error class: unknown class><SocketConnection>

This is a helper function for g_socket_client_connect().

Link copied to clipboard
open fun connectToUriAsync(uri: String, defaultPort: <Error class: unknown class>, cancellable: Cancellable? = null, callback: AsyncReadyCallback?)

This is the asynchronous version of g_socket_client_connect_to_uri().

Link copied to clipboard
open fun connectToUriFinish(result: AsyncResult): <Error class: unknown class><SocketConnection>

Finishes an async connect operation. See g_socket_client_connect_to_uri_async()

Link copied to clipboard

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().

Link copied to clipboard

Gets the socket type of the socket client.

Link copied to clipboard
open fun setProxyResolver(proxyResolver: ProxyResolver? = null)

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.

Link copied to clipboard
open fun setSocketType(type: SocketType)

Sets the socket type of the socket client. The sockets created by this object will be of the specified type.