UnixConnection

This is the subclass of GSocketConnection that is created for UNIX domain sockets.

It contains functions to do some of the UNIX socket specific functionality like passing file descriptors.

Note that <gio/gunixconnection.h> belongs to the UNIX-specific GIO interfaces, thus you have to use the gio-unix-2.0.pc pkg-config file when using it.

Constructors

this
this(GUnixConnection* gUnixConnection)

Sets our main struct and passes it to the parent class

Members

Functions

getStruct
void* getStruct()

the main Gtk struct as a void*

getUnixConnectionStruct
GUnixConnection* getUnixConnectionStruct()

Get the main Gtk struct

receiveCredentials
Credentials receiveCredentials(Cancellable cancellable)

Receives credentials from the sending end of the connection. The sending end has to call g_unix_connection_send_credentials() (or similar) for this to work. As well as reading the credentials this also reads (and discards) a single byte from the stream, as this is required for credentials passing to work on some implementations. Other ways to exchange credentials with a foreign peer includes the GUnixCredentialsMessage type and g_socket_get_credentials() function. Since 2.26

receiveCredentialsAsync
void receiveCredentialsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously receive credentials. For more details, see g_unix_connection_receive_credentials() which is the synchronous version of this call. When the operation is finished, callback will be called. You can then call g_unix_connection_receive_credentials_finish() to get the result of the operation. Since 2.32

receiveCredentialsFinish
Credentials receiveCredentialsFinish(AsyncResultIF result)

Finishes an asynchronous receive credentials operation started with g_unix_connection_receive_credentials_async(). Since 2.32

receiveFd
int receiveFd(Cancellable cancellable)

Receives a file descriptor from the sending end of the connection. The sending end has to call g_unix_connection_send_fd() for this to work. As well as reading the fd this also reads a single byte from the stream, as this is required for fd passing to work on some implementations. Since 2.22

sendCredentials
int sendCredentials(Cancellable cancellable)

Passes the credentials of the current user the receiving side of the connection. The receiving end has to call g_unix_connection_receive_credentials() (or similar) to accept the credentials. As well as sending the credentials this also writes a single NUL byte to the stream, as this is required for credentials passing to work on some implementations. Other ways to exchange credentials with a foreign peer includes the GUnixCredentialsMessage type and g_socket_get_credentials() function. Since 2.26

sendCredentialsAsync
void sendCredentialsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Asynchronously send credentials. For more details, see g_unix_connection_send_credentials() which is the synchronous version of this call. When the operation is finished, callback will be called. You can then call g_unix_connection_send_credentials_finish() to get the result of the operation. Since 2.32

sendCredentialsFinish
int sendCredentialsFinish(AsyncResultIF result)

Finishes an asynchronous send credentials operation started with g_unix_connection_send_credentials_async(). Since 2.32

sendFd
int sendFd(int fd, Cancellable cancellable)

Passes a file descriptor to the receiving side of the connection. The receiving end has to call g_unix_connection_receive_fd() to accept the file descriptor. As well as sending the fd this also writes a single byte to the stream, as this is required for fd passing to work on some implementations. Since 2.22

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

gUnixConnection
GUnixConnection* gUnixConnection;

the main Gtk struct

Inherited Members

From SocketConnection

gSocketConnection
GSocketConnection* gSocketConnection;

the main Gtk struct

getSocketConnectionStruct
GSocketConnection* getSocketConnectionStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
connect
int connect(SocketAddress address, Cancellable cancellable)

Connect connection to the specified remote address. Since 2.32

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

Asynchronously connect connection to the specified remote address. This clears the "blocking" flag on connection's underlying socket if it is currently set. Use g_socket_connection_connect_finish() to retrieve the result. Since 2.32

connectFinish
int connectFinish(AsyncResultIF result)

Gets the result of a g_socket_connection_connect_async() call. Since 2.32

isConnected
int isConnected()

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

getLocalAddress
SocketAddress getLocalAddress()

Try to get the local address of a socket connection. Since 2.22

getRemoteAddress
SocketAddress getRemoteAddress()

Try to get the remote address of a socket connection. Since 2.22

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. Since 2.22

factoryCreateConnection
SocketConnection factoryCreateConnection(Socket socket)

Creates a GSocketConnection subclass of the right type for socket. Since 2.22

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. If no type is registered, the GSocketConnection base type is returned. Since 2.22

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. If no type is registered, the GSocketConnection base type is returned. Since 2.22

Meta