| Safe Haskell | Safe-Infered |
|---|
Network.NetSpec.ByteString
Contents
Description
Use Lazy ByteStrings to send and receive messages.
For this module, a message is prefixed by a
64-bit little-endian signed integer, indicating the length in bytes
of the remaining message.
- receive :: MonadIO io => Handle -> io ByteString
- (!) :: (CanSend h, MonadIO io) => h -> ByteString -> io ()
- send :: MonadIO io => Handle -> ByteString -> io ()
- broadcast :: MonadIO io => Foldable f => f Handle -> ByteString -> io ()
Receiving
receive :: MonadIO io => Handle -> io ByteStringSource
Receive a ByteString message from a Handle.
Sending
(!) :: (CanSend h, MonadIO io) => h -> ByteString -> io ()Source
The staple for sending a message.
! is typeclassed so that you can
send or broadcast using the same simple syntax.
The CanSend typeclass is not exposed.
Instances of CanSend include Handle
and Traversable t => t Handle.
! produces an IO action lifted into any MonadIO,
so can be used without the extra cruft of liftIO
for most monad stacks. ! is declared as infix 2.
Usage:
destination ! someByteString
send :: MonadIO io => Handle -> ByteString -> io ()Source
Send a ByteString message to exactly one Handle.
broadcast :: MonadIO io => Foldable f => f Handle -> ByteString -> io ()Source
Broadcast a ByteString message to multiple Handles.