Network streams for use with strict
ByteStrings. For lazy ByteString's, see
Network.ByteString.Lazy.Stream. Use this module with
Serialize to send data over a stream without worrying
about sending and receiving the lengths.
One can also send data in chunks, sending data whenever it is ready, and the data will be collected transparently to the client interface.
- data Result a
- data Stream
- invalidate :: Stream -> IO ()
- withStream :: Handle -> (Stream -> IO (Result a)) -> IO a
- write :: Stream -> ByteString -> IO ()
- send :: Serialize a => Handle -> a -> IO ()
- receive :: Handle -> IO (Maybe ByteString)
- receiveE :: MonadIO m => Handle -> Iteratee ByteString m b -> m (Maybe b)
Represents whether the stream transaction was a success or a failure;
nothing is done by the library with the attached value. If you do not need
to send back a value to the caller of
withStream, you can use
Doesn't fail, but tells the client that all the data sent by the stream so far has been invalidated, and hence the queue of messages to be sent is cleared.
Opens a stream using the given handle and passes it to the function, and then unwraps the result given and gives any user data that the specific function wants to give back.
Writes partial or full data over a
Stream, placing it in the queue
of all of the partial data.
Serializes data and sends it over a newly created
Enumerator-based version of receive that allows the client to fold over
the data as it is being received. Each
ByteString is a single chunk sent
write. Keep in mind that any IO performed is dangerous if you are
possibly expected an Invalidation, since then that IO could end up being
incorrect. Hence, it is more useful to simply use this in a pure manner to
build up some result data as the bytes are being streamed in.