netlines-0.2.0: Enumerator tools for text-based network protocols

MaintainerErtugrul Soeylemez <>




Enumerator tools for working with text-based network protocols.


Conversion to lines

netLine :: forall m r. Monad m => Int -> MaybeT r (Iteratee ByteString m) ByteStringSource

Savely read a line with the given maximum length. If a longer line is enumerated, the excess data is dropped in constant space. Returns Nothing on EOF.

Please note that this function is very error-tolerant in the way it handles line endings. Both CR and LF are proper line terminators. This function ignores empty lines.

netLines :: forall b m. Monad m => Int -> Enumeratee ByteString ByteString m bSource

Convert a stream of bytes to a stream of lines with the given maximum length. Longer lines are silently truncated in constant space.

Conversion to sparse lines

netLineEmpty :: forall m. Monad m => Int -> Iteratee ByteString m (Maybe ByteString)Source

Variant of netLine, which supports empty lines, useful for protocols like HTTP, in which empty lines have a special meaning. This function splits the input stream by LF characters while simply ignoring CR characters.

netLinesEmpty :: forall b m. Monad m => Int -> Enumeratee ByteString ByteString m bSource

This is the same like netLines, but is based on netLinesEmpty to support empty lines.


enumHandleTimeout :: forall b m. MonadIO m => Int -> Int -> Handle -> Enumerator ByteString m bSource

Enumerate from a handle with the given buffer size (first argument) and timeout in milliseconds (second argument). If the timeout is exceeded an exception is thrown via throwError.