network-mux-0.2.0.0: Multiplexing library
Safe HaskellNone
LanguageHaskell2010

Network.Mux.Channel

Description

An extension of Channel, with additional Channel implementations.

Synopsis

Documentation

data Channel m Source #

Constructors

Channel 

Fields

  • sendByteString → m ()

    Write bytes to the channel.

    It maybe raise exceptions.

  • recv ∷ m (Maybe ByteString)

    Read some input from the channel, or Nothing to indicate EOF.

    Note that having received EOF it is still possible to send. The EOF condition is however monotonic.

    It may raise exceptions (as appropriate for the monad and kind of channel).

createBufferConnectedChannels ∷ ∀ m. MonadSTM m ⇒ m (Channel m, Channel m) Source #

Create a pair of Channels that are connected internally.

This is intended for inter-thread communication, such as between a multiplexing thread and a thread running a peer.

It uses lazy ByteStrings but it ensures that data written to the channel is fully evaluated first. This ensures that any work to serialise the data takes place on the writer side and not the reader side.

createPipeConnectedChannelsIO (Channel IO, Channel IO) Source #

Create a local pipe, with both ends in this process, and expose that as a pair of Channels, one for each end.

This is primarily for testing purposes since it does not allow actual IPC.

createSocketConnectedChannels Source #

Arguments

∷ Family

Usually AF_UNIX or AF_INET

IO (Channel IO, Channel IO) 

withFifosAsChannel Source #

Arguments

FilePath

FIFO for reading

FilePath

FIFO for writing

→ (Channel IOIO a) 
IO a 

Open a pair of Unix FIFOs, and expose that as a Channel.

The peer process needs to open the same files but the other way around, for writing and reading.

This is primarily for the purpose of demonstrations that use communication between multiple local processes. It is Unix specific.

socketAsChannel ∷ Socket → Channel IO Source #

Make a Channel from a Socket. The socket must be a stream socket

channelEffect Source #

Arguments

∷ ∀ m. Monad m 
⇒ (ByteString → m ())

Action before send

→ (Maybe ByteString → m ())

Action after recv

Channel m 
Channel m 

delayChannel ∷ MonadTimer m ⇒ DiffTimeChannel m → Channel m Source #

Delay a channel on the receiver end.

This is intended for testing, as a crude approximation of network delays. More accurate models along these lines are of course possible.

loggingChannel ∷ (MonadSay m, Show id) ⇒ id → Channel m → Channel m Source #

Channel which logs sent and received messages.