Data.BinaryCom
Description
Binary Communicator
This module provides the datatype BinaryCom, which enables you
to easily send and receive data to and from a binary source.
The transmitted data can be an instance of the Binary class,
or you can provide your own Put and Get actions to serialize
and parse the binary stream.
- data BinaryCom
- binaryCom :: MonadIO m => Handle -> m BinaryCom
- binaryCom2H :: MonadIO m => Handle -> Handle -> m BinaryCom
- binaryComBS :: MonadIO m => ByteString -> Handle -> m BinaryCom
- send :: (Binary a, MonadIO m) => BinaryCom -> a -> m ()
- flush :: MonadIO m => BinaryCom -> m ()
- sendFlush :: (Binary a, MonadIO m) => BinaryCom -> a -> m ()
- receive :: (Binary a, MonadIO m) => BinaryCom -> m a
- sendPut :: MonadIO m => BinaryCom -> Put -> m ()
- receiveGet :: MonadIO m => BinaryCom -> Get a -> m a
Documentation
Arguments
| :: MonadIO m | |
| => ByteString | For reading |
| -> Handle | For writing |
| -> m BinaryCom | New |
Creates a BinaryCom from a lazy ByteString (for reading) and a Handle (for writing)
send :: (Binary a, MonadIO m) => BinaryCom -> a -> m ()Source
Sends a serializable value through a BinaryCom
flush :: MonadIO m => BinaryCom -> m ()Source
Flushes a BinaryCom. Do not forget to do this after sending!
sendFlush :: (Binary a, MonadIO m) => BinaryCom -> a -> m ()Source
Shortcut for sending a value and flushing the BinaryCom