gi-gio-2.0.19: Gio bindings

Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com)
Safe Haskell | None
Language | Haskell2010

GI.Gio.Objects.UnixConnection

Contents

- Exported types
- Methods
  - receiveCredentials
  - receiveCredentialsAsync
  - receiveCredentialsFinish
  - receiveFd
  - sendCredentials
  - sendCredentialsAsync
  - sendCredentialsFinish
  - sendFd

Description

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.

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.

Since: 2.22

Synopsis

- newtype UnixConnection = UnixConnection (ManagedPtr UnixConnection)
- class GObject o => IsUnixConnection o
- toUnixConnection :: (MonadIO m, IsUnixConnection o) => o -> m UnixConnection
- noUnixConnection :: Maybe UnixConnection
- unixConnectionReceiveCredentials :: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) => a -> Maybe b -> m Credentials
- unixConnectionReceiveCredentialsAsync :: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- unixConnectionReceiveCredentialsFinish :: (HasCallStack, MonadIO m, IsUnixConnection a, IsAsyncResult b) => a -> b -> m Credentials
- unixConnectionReceiveFd :: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) => a -> Maybe b -> m Int32
- unixConnectionSendCredentials :: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) => a -> Maybe b -> m ()
- unixConnectionSendCredentialsAsync :: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- unixConnectionSendCredentialsFinish :: (HasCallStack, MonadIO m, IsUnixConnection a, IsAsyncResult b) => a -> b -> m ()
- unixConnectionSendFd :: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) => a -> Int32 -> Maybe b -> m ()

# Exported types

newtype UnixConnection Source #

Memory-managed wrapper type.

Constructors

UnixConnection (ManagedPtr UnixConnection) |

Instances

GObject UnixConnection Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection Methods gobjectType :: UnixConnection -> IO GType Source #
IsObject UnixConnection Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection
IsIOStream UnixConnection Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection
IsSocketConnection UnixConnection Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection
IsUnixConnection UnixConnection Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection

class GObject o => IsUnixConnection o Source #

Type class for types which can be safely cast to `UnixConnection`, for instance with `toUnixConnection`.

Instances

(GObject a, (UnknownAncestorError UnixConnection a :: Constraint)) => IsUnixConnection a Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection
IsUnixConnection UnixConnection Source # |
Instance details Defined in GI.Gio.Objects.UnixConnection

toUnixConnection :: (MonadIO m, IsUnixConnection o) => o -> m UnixConnection Source #

Cast to `UnixConnection`, for types for which this is known to be safe. For general casts, use `castTo`.

noUnixConnection :: Maybe UnixConnection Source #

A convenience alias for `Nothing` :: `Maybe` `UnixConnection`.

# Methods

## receiveCredentials

unixConnectionReceiveCredentials Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) |
=> a | `connection`: A `UnixConnection`.
-> Maybe b | `cancellable`: A `Cancellable` or `Nothing`.
-> m Credentials | Returns: Received credentials on success (free with `objectUnref`), `Nothing` if `error` is set. (Can throw `GError`)

Receives credentials from the sending end of the connection. The sending end has to call `unixConnectionSendCredentials` (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 `UnixCredentialsMessage` type and `socketGetCredentials` function.

Since: 2.26

## receiveCredentialsAsync

unixConnectionReceiveCredentialsAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) |
=> a | `connection`: A `UnixConnection`.
-> Maybe b | `cancellable`: optional `Cancellable` object, `Nothing` to ignore.
-> Maybe AsyncReadyCallback | `callback`: a `AsyncReadyCallback` to call when the request is satisfied
-> m () |

Asynchronously receive credentials.

For more details, see `unixConnectionReceiveCredentials` which is the synchronous version of this call.

When the operation is finished, `callback` will be called. You can then call `unixConnectionReceiveCredentialsFinish` to get the result of the operation.

Since: 2.32

## receiveCredentialsFinish

unixConnectionReceiveCredentialsFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsAsyncResult b) |
=> a | `connection`: A `UnixConnection`.
-> b | `result`: a `AsyncResult`.
-> m Credentials | Returns: a `Credentials`, or `Nothing` on error. Free the returned object with `objectUnref`. (Can throw `GError`)

Finishes an asynchronous receive credentials operation started with `unixConnectionReceiveCredentialsAsync`.

Since: 2.32

## receiveFd

unixConnectionReceiveFd Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) |
=> a | `connection`: a `UnixConnection`
-> Maybe b | `cancellable`: optional `Cancellable` object, `Nothing` to ignore
-> m Int32 | Returns: a file descriptor on success, -1 on error. (Can throw `GError`)

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

unixConnectionSendCredentials Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) |
=> a | `connection`: A `UnixConnection`.
-> Maybe b | `cancellable`: A `Cancellable` or `Nothing`.
-> m () | (Can throw `GError`)

Passes the credentials of the current user the receiving side of the connection. The receiving end has to call `unixConnectionReceiveCredentials` (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 `UnixCredentialsMessage` type and `socketGetCredentials` function.

Since: 2.26

## sendCredentialsAsync

unixConnectionSendCredentialsAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) |
=> a | `connection`: A `UnixConnection`.
-> Maybe b | `cancellable`: optional `Cancellable` object, `Nothing` to ignore.
-> Maybe AsyncReadyCallback | `callback`: a `AsyncReadyCallback` to call when the request is satisfied
-> m () |

Asynchronously send credentials.

For more details, see `unixConnectionSendCredentials` which is the synchronous version of this call.

When the operation is finished, `callback` will be called. You can then call `unixConnectionSendCredentialsFinish` to get the result of the operation.

Since: 2.32

## sendCredentialsFinish

unixConnectionSendCredentialsFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsAsyncResult b) |
=> a | `connection`: A `UnixConnection`.
-> b | `result`: a `AsyncResult`.
-> m () | (Can throw `GError`)

Finishes an asynchronous send credentials operation started with `unixConnectionSendCredentialsAsync`.

Since: 2.32

## sendFd

unixConnectionSendFd Source #

Arguments

:: (HasCallStack, MonadIO m, IsUnixConnection a, IsCancellable b) |
=> a | `connection`: a `UnixConnection`
-> Int32 | `fd`: a file descriptor
-> Maybe b | `cancellable`: optional `Cancellable` object, `Nothing` to ignore.
-> m () | (Can throw `GError`)

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