SocketConnection

#GSocketConnection is a #GIOStream for a connected socket. They can be created either by #GSocketClient when connecting to a host, or by #GSocketListener 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 #GTcpConnection.

Choosing what type of object to construct is done with the socket connection factory, and it is possible for 3rd parties to register custom socket connection types for specific combination of socket family/type/protocol using g_socket_connection_factory_register_type().

To close a #GSocketConnection, use g_io_stream_close(). Closing both substreams of the #GIOStream separately will not close the underlying #GSocket.

Constructors

this
this(GSocketConnection* gSocketConnection, bool ownedRef)

Sets our main struct and passes it to the parent class.

Members

Functions

connect
bool connect(SocketAddress address, Cancellable cancellable)

Connect @connection to the specified remote address.

connectAsync
void connectAsync(SocketAddress address, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously connect @connection to the specified remote address.

connectFinish
bool connectFinish(AsyncResultIF result)

Gets the result of a g_socket_connection_connect_async() call.

getLocalAddress
SocketAddress getLocalAddress()

Try to get the local address of a socket connection.

getRemoteAddress
SocketAddress getRemoteAddress()

Try to get the remote address of a socket connection.

getSocket
Socket getSocket()

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.

getSocketConnectionStruct
GSocketConnection* getSocketConnectionStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

isConnected
bool isConnected()

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

Static functions

factoryLookupType
GType factoryLookupType(GSocketFamily family, GSocketType type, int protocolId)

Looks up the #GType to be used when creating socket connections on sockets with the specified @family, @type and @protocol_id.

factoryRegisterType
void factoryRegisterType(GType gType, GSocketFamily family, GSocketType type, int protocol)

Looks up the #GType to be used when creating socket connections on sockets with the specified @family, @type and @protocol.

getType
GType getType()

Variables

gSocketConnection
GSocketConnection* gSocketConnection;

the main Gtk struct

Inherited Members

From IOStream

gIOStream
GIOStream* gIOStream;

the main Gtk struct

getIOStreamStruct
GIOStream* getIOStreamStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
spliceFinish
bool spliceFinish(AsyncResultIF result)

Finishes an asynchronous io stream splice operation.

clearPending
void clearPending()

Clears the pending flag on @stream.

close
bool close(Cancellable cancellable)

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

closeAsync
void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

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.

closeFinish
bool closeFinish(AsyncResultIF result)

Closes a stream.

getInputStream
InputStream getInputStream()

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

getOutputStream
OutputStream getOutputStream()

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

hasPending
bool hasPending()

Checks if a stream has pending actions.

isClosed
bool isClosed()

Checks if a stream is closed.

setPending
bool setPending()

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

spliceAsync
void spliceAsync(IOStream stream2, GIOStreamSpliceFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asyncronously splice the output stream of @stream1 to the input stream of @stream2, and splice the output stream of @stream2 to the input stream of @stream1.

Meta

Since

2.22