:right-sidebar: True UnixConnection =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.22 .. class:: UnixConnection(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gio.SocketConnection`, :class:`~gi.repository.Gio.IOStream`, :class:`~gi.repository.GObject.Object` This is the subclass of :obj:`~gi.repository.Gio.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, ```` 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 ------- .. rst-class:: interim-class .. class:: UnixConnection :no-index: .. method:: receive_credentials(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.Credentials Receives credentials from the sending end of the connection. The sending end has to call :func:`~gi.repository.Gio.UnixConnection.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 :obj:`~gi.repository.Gio.UnixCredentialsMessage` type and :func:`~gi.repository.Gio.Socket.get_credentials` function. .. versionadded:: 2.26 :param cancellable: A :obj:`~gi.repository.Gio.Cancellable` or :const:`None`. .. method:: receive_credentials_async(self) -> ~gi.repository.Gio.Credentials :async: This is the `awaitable `_ version of :meth:`receive_credentials_async`. .. versionadded:: 2.32 .. method:: receive_credentials_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously receive credentials. For more details, see :func:`~gi.repository.Gio.UnixConnection.receive_credentials` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.UnixConnection.receive_credentials_finish` to get the result of the operation. .. versionadded:: 2.32 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: receive_credentials_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.Credentials Finishes an asynchronous receive credentials operation started with :func:`~gi.repository.Gio.UnixConnection.receive_credentials_async`. .. versionadded:: 2.32 :param result: a :obj:`~gi.repository.Gio.AsyncResult`\. .. method:: receive_fd(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> int Receives a file descriptor from the sending end of the connection. The sending end has to call :func:`~gi.repository.Gio.UnixConnection.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. .. versionadded:: 2.22 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore .. method:: send_credentials(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Passes the credentials of the current user the receiving side of the connection. The receiving end has to call :func:`~gi.repository.Gio.UnixConnection.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 :obj:`~gi.repository.Gio.UnixCredentialsMessage` type and :func:`~gi.repository.Gio.Socket.get_credentials` function. .. versionadded:: 2.26 :param cancellable: A :obj:`~gi.repository.Gio.Cancellable` or :const:`None`. .. method:: send_credentials_async(self) -> bool :async: This is the `awaitable `_ version of :meth:`send_credentials_async`. .. versionadded:: 2.32 .. method:: send_credentials_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously send credentials. For more details, see :func:`~gi.repository.Gio.UnixConnection.send_credentials` which is the synchronous version of this call. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.Gio.UnixConnection.send_credentials_finish` to get the result of the operation. .. versionadded:: 2.32 :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: send_credentials_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous send credentials operation started with :func:`~gi.repository.Gio.UnixConnection.send_credentials_async`. .. versionadded:: 2.32 :param result: a :obj:`~gi.repository.Gio.AsyncResult`\. .. method:: send_fd(fd: int, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool Passes a file descriptor to the receiving side of the connection. The receiving end has to call :func:`~gi.repository.Gio.UnixConnection.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. .. versionadded:: 2.22 :param fd: a file descriptor :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. Fields ------ .. rst-class:: interim-class .. class:: UnixConnection :no-index: .. attribute:: parent_instance .. attribute:: priv