SocketConnection

open class SocketConnection(pointer: <Error class: unknown class><<Error class: unknown class>>) : IOStream

GSocketConnection is a class@Gio.IOStream for a connected socket. They can be created either by class@Gio.SocketClient when connecting to a host, or by class@Gio.SocketListener when accepting a new client.

The type of the GSocketConnection object returned from these calls 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.

Choosing what type of object to construct is done with the socket connection factory, and it is possible for third parties to register custom socket connection types for specific combination of socket family/type/protocol using func@Gio.SocketConnection.factory_register_type.

To close a GSocketConnection, use method@Gio.IOStream.close. Closing both substreams of the class@Gio.IOStream separately will not close the underlying class@Gio.Socket.

Since

2.22

Inheritors

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val gioIOStreamPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
val gioSocketConnectionPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

The class@Gio.InputStream to read from.

Link copied to clipboard

The class@Gio.OutputStream to write to.

Link copied to clipboard
open val socket: Socket

The underlying class@Gio.Socket.

Functions

Link copied to clipboard
open fun clearPending()

Clears the pending flag on @stream.

Link copied to clipboard
open fun close(cancellable: Cancellable? = null): <Error class: unknown class><Boolean>

Closes the stream, releasing resources related to it. This will also close the individual input and output streams, if they are not already closed.

Link copied to clipboard
open fun closeAsync(ioPriority: Int, cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Requests an asynchronous close of the stream, releasing resources related to it. When the operation is finished @callback will be called. You can then call g_io_stream_close_finish() to get the result of the operation.

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

Closes a stream.

Link copied to clipboard
open fun connect(address: SocketAddress, cancellable: Cancellable? = null): <Error class: unknown class><Boolean>

Connect @connection to the specified remote address.

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

Asynchronously connect @connection to the specified remote address.

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

Gets the result of a g_socket_connection_connect_async() call.

Link copied to clipboard

Gets the input stream for this object. This is used for reading.

Link copied to clipboard
open fun getLocalAddress(): <Error class: unknown class><SocketAddress>

Try to get the local address of a socket connection.

Link copied to clipboard

Gets the output stream for this object. This is used for writing.

Link copied to clipboard
open fun getRemoteAddress(): <Error class: unknown class><SocketAddress>

Try to get the remote address of a socket connection.

Link copied to clipboard
open fun getSocket(): Socket

Gets the underlying #GSocket object of the connection. This can be useful if you want to do something unusual on it not supported by the #GSocketConnection APIs.

Link copied to clipboard
open fun hasPending(): Boolean

Checks if a stream has pending actions.

Link copied to clipboard
open fun isClosed(): Boolean

Checks if a stream is closed.

Link copied to clipboard
open fun isConnected(): Boolean

Checks if @connection is connected. This is equivalent to calling g_socket_is_connected() on @connection's underlying #GSocket.

Link copied to clipboard
open fun setPending(): <Error class: unknown class><Boolean>

Sets @stream to have actions pending. If the pending flag is already set or @stream is closed, it will return false and set

Link copied to clipboard
open fun spliceAsync(stream2: IOStream, flags: IOStreamSpliceFlags, ioPriority: Int, cancellable: Cancellable? = null, callback: AsyncReadyCallback)

Asynchronously splice the output stream of @stream1 to the input stream of