UnixConnection#

Added in version 2.22.

class UnixConnection(**properties: Any)#

Superclasses: SocketConnection, IOStream, Object

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

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

Since GLib 2.72, GUnixConnection is available on all platforms. It requires underlying system support (such as Windows 10 with AF_UNIX) at run time.

Before GLib 2.72, <gio/gunixconnection.h> belonged to the UNIX-specific GIO interfaces, thus you had to use the gio-unix-2.0.pc pkg-config file when using it. This is no longer necessary since GLib 2.72.

Methods#

class UnixConnection
receive_credentials(cancellable: Cancellable | None = None) Credentials#

Receives credentials from the sending end of the connection. The sending end has to call 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.

This method can be expected to be available on the following platforms:

  • Linux since GLib 2.26

  • FreeBSD since GLib 2.26

  • GNU/kFreeBSD since GLib 2.36

  • Solaris, Illumos and OpenSolaris since GLib 2.40

  • GNU/Hurd since GLib 2.40

Other ways to exchange credentials with a foreign peer includes the UnixCredentialsMessage type and get_credentials() function.

Added in version 2.26.

Parameters:

cancellable – A Cancellable or None.

receive_credentials_async(cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None#

Asynchronously receive credentials.

For more details, see receive_credentials() which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call receive_credentials_finish() to get the result of the operation.

Added in version 2.32.

Parameters:
  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback to call when the request is satisfied

  • user_data – the data to pass to callback function

receive_credentials_finish(result: AsyncResult) Credentials#

Finishes an asynchronous receive credentials operation started with receive_credentials_async().

Added in version 2.32.

Parameters:

result – a AsyncResult.

receive_fd(cancellable: Cancellable | None = None) int#

Receives a file descriptor from the sending end of the connection. The sending end has to call 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.

Added in version 2.22.

Parameters:

cancellable – optional Cancellable object, None to ignore

send_credentials(cancellable: Cancellable | None = None) bool#

Passes the credentials of the current user the receiving side of the connection. The receiving end has to call 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.

This method can be expected to be available on the following platforms:

  • Linux since GLib 2.26

  • FreeBSD since GLib 2.26

  • GNU/kFreeBSD since GLib 2.36

  • Solaris, Illumos and OpenSolaris since GLib 2.40

  • GNU/Hurd since GLib 2.40

Other ways to exchange credentials with a foreign peer includes the UnixCredentialsMessage type and get_credentials() function.

Added in version 2.26.

Parameters:

cancellable – A Cancellable or None.

send_credentials_async(cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None#

Asynchronously send credentials.

For more details, see send_credentials() which is the synchronous version of this call.

When the operation is finished, callback will be called. You can then call send_credentials_finish() to get the result of the operation.

Added in version 2.32.

Parameters:
  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback to call when the request is satisfied

  • user_data – the data to pass to callback function

send_credentials_finish(result: AsyncResult) bool#

Finishes an asynchronous send credentials operation started with send_credentials_async().

Added in version 2.32.

Parameters:

result – a AsyncResult.

send_fd(fd: int, cancellable: Cancellable | None = None) bool#

Passes a file descriptor to the receiving side of the connection. The receiving end has to call 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.

Added in version 2.22.

Parameters:
  • fd – a file descriptor

  • cancellable – optional Cancellable object, None to ignore.

Fields#

class UnixConnection
parent_instance#
priv#