DBus.Transport

dbus-0.10.12: A client library for the D-Bus IPC system.

Safe Haskell | None
Language | Haskell98

DBus.Transport

Contents

- Transports
- Transport errors
- Socket transport

Description

Support for defining custom transport mechanisms. Most users will not need to care about the types defined in this module.

Synopsis

- class Transport t where
  - data TransportOptions t :: *
- class Transport t => TransportOpen t where
- class Transport t => TransportListen t where
  - data TransportListener t :: *
- data TransportError
- transportError :: String -> TransportError
- transportErrorMessage :: TransportError -> String
- transportErrorAddress :: TransportError -> Maybe Address
- data SocketTransport
- socketTransportOptionBacklog :: TransportOptions SocketTransport -> Int
- socketTransportCredentials :: SocketTransport -> IO (CUInt, CUInt, CUInt)

# Transports

class Transport t where #

A `Transport` can exchange bytes with a remote peer.

Minimal complete definition

transportDefaultOptions, transportPut, transportGet, transportClose

Associated Types

data TransportOptions t :: * #

Additional options that this transport type may use when establishing a connection.

Methods

transportDefaultOptions :: TransportOptions t #

Default values for this transport's options.

transportPut :: t -> ByteString -> IO () #

Send a `ByteString` over the transport.

Throws a `TransportError` if an error occurs.

transportGet :: t -> Int -> IO ByteString #

Receive a `ByteString` of the given size from the transport. The transport should block until sufficient bytes are available, and only return fewer than the requested amount if there will not be any more data.

Throws a `TransportError` if an error occurs.

transportClose :: t -> IO () #

Close an open transport, and release any associated resources or handles.

Instances

Transport SocketTransport # |
Associated Types data TransportOptions SocketTransport :: * # Methods transportDefaultOptions :: TransportOptions SocketTransport # transportPut :: SocketTransport -> ByteString -> IO () # transportGet :: SocketTransport -> Int -> IO ByteString # transportClose :: SocketTransport -> IO () #

class Transport t => TransportOpen t where #

A `Transport` which can open a connection to a remote peer.

Minimal complete definition

transportOpen

Methods

transportOpen :: TransportOptions t -> Address -> IO t #

Open a connection to the given address, using the given options.

Throws a `TransportError` if the connection could not be established.

Instances

TransportOpen SocketTransport # |
Methods transportOpen :: TransportOptions SocketTransport -> Address -> IO SocketTransport #

class Transport t => TransportListen t where #

A `Transport` which can listen for and accept connections from remote peers.

Minimal complete definition

transportListen, transportAccept, transportListenerClose, transportListenerAddress, transportListenerUUID

Associated Types

data TransportListener t :: * #

Used for transports that listen on a port or address.

Methods

transportListen :: TransportOptions t -> Address -> IO (TransportListener t) #

Begin listening for connections on the given address, using the given options.

Throws a `TransportError` if it's not possible to listen at that address (for example, if the port is already in use).

transportAccept :: TransportListener t -> IO t #

Accept a new connection.

Throws a `TransportError` if some error happens before the transport is ready to exchange bytes.

transportListenerClose :: TransportListener t -> IO () #

Close an open listener.

transportListenerAddress :: TransportListener t -> Address #

Get the address to use to connect to a listener.

transportListenerUUID :: TransportListener t -> UUID #

Get the UUID allocated to this transport listener.

See `randomUUID`.

Instances

TransportListen SocketTransport # |
Associated Types data TransportListener SocketTransport :: * # Methods transportListen :: TransportOptions SocketTransport -> Address -> IO (TransportListener SocketTransport) # transportAccept :: TransportListener SocketTransport -> IO SocketTransport # transportListenerClose :: TransportListener SocketTransport -> IO () # transportListenerAddress :: TransportListener SocketTransport -> Address # transportListenerUUID :: TransportListener SocketTransport -> UUID #

# Transport errors

data TransportError #

Thrown from transport methods when an error occurs.

Instances

Eq TransportError # |
Methods (==) :: TransportError -> TransportError -> Bool # (/=) :: TransportError -> TransportError -> Bool #
Show TransportError # |
Methods showsPrec :: Int -> TransportError -> ShowS # show :: TransportError -> String # showList :: [TransportError] -> ShowS #
Exception TransportError # |
Methods toException :: TransportError -> SomeException # fromException :: SomeException -> Maybe TransportError # displayException :: TransportError -> String #

transportError :: String -> TransportError #

transportErrorMessage :: TransportError -> String #

transportErrorAddress :: TransportError -> Maybe Address #

# Socket transport

data SocketTransport #

Supports connecting over Unix or TCP sockets.

Unix sockets are similar to pipes, but exist as special files in the filesystem. On Linux, abstract sockets have a path-like address, but do not actually have entries in the filesystem.

TCP sockets may use either IPv4 or IPv6.

Instances

TransportListen SocketTransport # |
Associated Types data TransportListener SocketTransport :: * # Methods transportListen :: TransportOptions SocketTransport -> Address -> IO (TransportListener SocketTransport) # transportAccept :: TransportListener SocketTransport -> IO SocketTransport # transportListenerClose :: TransportListener SocketTransport -> IO () # transportListenerAddress :: TransportListener SocketTransport -> Address # transportListenerUUID :: TransportListener SocketTransport -> UUID #
TransportOpen SocketTransport # |
Methods transportOpen :: TransportOptions SocketTransport -> Address -> IO SocketTransport #
Transport SocketTransport # |
Associated Types data TransportOptions SocketTransport :: * # Methods transportDefaultOptions :: TransportOptions SocketTransport # transportPut :: SocketTransport -> ByteString -> IO () # transportGet :: SocketTransport -> Int -> IO ByteString # transportClose :: SocketTransport -> IO () #
data TransportListener SocketTransport # |
data TransportListener SocketTransport = SocketTransportListener Address UUID Socket
data TransportOptions SocketTransport # |
data TransportOptions SocketTransport = SocketTransportOptions { socketTransportOptionBacklog :: Int }

socketTransportOptionBacklog :: TransportOptions SocketTransport -> Int #

The maximum size of the connection queue for a listening socket.

socketTransportCredentials :: SocketTransport -> IO (CUInt, CUInt, CUInt) #

Returns the processID, userID, and groupID of the socket's peer.

See `getPeerCred`.