binary-protocol-zmq-0.2: Monad to ease implementing a binary network protocol over ZeroMQ

Stabilityexperimental
MaintainerNicolas Trangez <eikke@eikke.com>
Safe HaskellNone

Control.Monad.BinaryProtocol.ZMQ

Description

Monad to ease implementing a binary network protocol over ZeroMQ

Synopsis

Documentation

data BinaryProtocol a b c Source

Action type definition. a is the type of the reader ZeroMQ socket, b is the type of the writer ZeroMQ socket, and c is the return type of the action.

runProtocol :: BinaryProtocol a b c -> Socket a -> Socket b -> IO cSource

Take a BinaryProtocol action and run it on the given ZeroMQ sockets for respectively reading and writing. The two given handles are allowed to be the same if the same handle is used for reading and writing.

Since ZeroMQ sockets are not thread-safe (unlike a Context object), make sure you use any socket you create in the OS thread it was created in only. Use forkOS where necessary.

receive :: Binary c => BinaryProtocol a b cSource

Read in a value of type c from the connection; c must be an instance of the Binary class. This is a wrapper around receive', not passing any flags.

receive' :: Binary c => [Flag] -> BinaryProtocol a b cSource

Read in a value of type c from the connection; c must be an instance of the Binary class. A list of Flags can be given.

send :: Binary c => c -> BinaryProtocol a b ()Source

Send a value of type c down the connection; c must be an instance of the Binary class. This is a wrapper aroung send', not passing any flags.

send' :: Binary c => [Flag] -> c -> BinaryProtocol a b ()Source

Send a value of type c down the connection; c must be an instance of the Binary class. A list of Flags can be given.

flush :: BinaryProtocol a b ()Source

Flush connections

Note: this is a no-op, provided for API compatibility with the Control.Monad.BinaryProtocol package.