Stability | experimental |
---|---|
Maintainer | Nicolas Trangez <eikke@eikke.com> |
Safe Haskell | None |
Control.Monad.BinaryProtocol.ZMQ
Description
Monad to ease implementing a binary network protocol over ZeroMQ
- data BinaryProtocol a b c
- runProtocol :: BinaryProtocol a b c -> Socket a -> Socket b -> IO c
- receive :: Binary c => BinaryProtocol a b c
- receive' :: Binary c => [Flag] -> BinaryProtocol a b c
- send :: Binary c => c -> BinaryProtocol a b ()
- send' :: Binary c => [Flag] -> c -> BinaryProtocol a b ()
- flush :: BinaryProtocol a b ()
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.
Instances
Monad (BinaryProtocol a b) | |
MonadIO (BinaryProtocol a b) | |
MonadReader (Socket a, Socket b) (BinaryProtocol a b) |
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 Flag
s 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 Flag
s 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.