Stability | beta |
---|---|
Maintainer | Ertugrul Soeylemez <es@ertes.de> |
Enumerator tools for working with text-based network protocols.
- netLine :: forall m. Monad m => Int -> Iteratee ByteString m (Maybe ByteString)
- netLineEmpty :: Monad m => Int -> Iteratee ByteString m (Maybe ByteString)
- netWord :: Monad m => Int -> Iteratee ByteString m (Maybe ByteString)
- netWordEmpty :: Monad m => Int -> Iteratee ByteString m (Maybe ByteString)
- netLines :: Monad m => Int -> Enumeratee ByteString ByteString m b
- netLinesEmpty :: Monad m => Int -> Enumeratee ByteString ByteString m b
- netWords :: Monad m => Int -> Enumeratee ByteString ByteString m b
- netWordsEmpty :: Monad m => Int -> Enumeratee ByteString ByteString m b
- netSplitBy :: forall m. Monad m => (Word8 -> Bool) -> (Word8 -> Bool) -> Int -> Iteratee ByteString m (Maybe ByteString)
- netSplitsBy :: forall b m. Monad m => Iteratee ByteString m (Maybe ByteString) -> Enumeratee ByteString ByteString m b
- newtype TimeoutError = TimeoutError {}
- enumHandleSession :: forall b m. MonadIO m => Int -> Int -> Int -> Handle -> Enumerator ByteString m b
- enumHandleTimeout :: forall b m. MonadIO m => Int -> Int -> Handle -> Enumerator ByteString m b
- iterHandleTimeout :: forall m. MonadIO m => Int -> Handle -> Iteratee ByteString m ()
Iteratees
netLine :: forall m. Monad m => Int -> Iteratee ByteString m (Maybe ByteString)Source
Get the next nonempty line from the stream using netLineEmpty
.
netLineEmpty :: Monad m => Int -> Iteratee ByteString m (Maybe ByteString)Source
Get the next line from the stream, length-limited by the given
Int
. This iteratee is error-tolerant by using LF as the line
terminator and simply ignoring all CR characters.
netWord :: Monad m => Int -> Iteratee ByteString m (Maybe ByteString)Source
Get the next nonempty word from the stream with the given maximum
length. Based on netWordEmpty
.
netWordEmpty :: Monad m => Int -> Iteratee ByteString m (Maybe ByteString)Source
Get the next word from the stream with the given maximum length. This iteratee is error-tolerant by using ASCII whitespace as splitting characters.
Enumeratees
netLines :: Monad m => Int -> Enumeratee ByteString ByteString m bSource
Convert a raw byte stream to a stream of lines based on netLine
.
netLinesEmpty :: Monad m => Int -> Enumeratee ByteString ByteString m bSource
Convert a raw byte stream to a stream of lines based on
netLineEmpty
.
netWords :: Monad m => Int -> Enumeratee ByteString ByteString m bSource
Split the raw byte stream into words based on netWord
.
netWordsEmpty :: Monad m => Int -> Enumeratee ByteString ByteString m bSource
Split the raw byte stream into words based on netWords
.
General stream splitters
netSplitBy :: forall m. Monad m => (Word8 -> Bool) -> (Word8 -> Bool) -> Int -> Iteratee ByteString m (Maybe ByteString)Source
Get the next token, where tokens are splitted by the first given
predicate and filtered by the second. Tokens are length-limited by
the given Int
and are truncated safely in constant space.
netSplitsBy :: forall b m. Monad m => Iteratee ByteString m (Maybe ByteString) -> Enumeratee ByteString ByteString m bSource
Split the stream using the supplied iteratee.
Input/output
newtype TimeoutError Source
Exception for timed out IO operations.
enumHandleSession :: forall b m. MonadIO m => Int -> Int -> Int -> Handle -> Enumerator ByteString m bSource
Enumerate from a handle with the given buffer size (first
argument), read timeout in milliseconds (second argument) and session
timeout in milliseconds (third argument). If either timeout is
exceeded a TimeoutError
exception is thrown via throwError
.
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 a TimeoutError
exception is thrown via throwError
.
Note that this timeout is not a timeout for the whole enumeration, but for each individual read operation. In other words, this timeout protects against dead/unresponsive peers, but not against (perhaps intentionally) slowly sending peers.
iterHandleTimeout :: forall m. MonadIO m => Int -> Handle -> Iteratee ByteString m ()Source
Writes its inputs to the given handle. Times out after the given
number of milliseconds with a TimeoutError
iteratee exception. The
handle should be unbuffered and in binary mode. See hSetBuffering
and hSetBinaryMode
.
Please note that only the write operations themselves are timed. Most notably the operation of the data source enumerator is *not* timed. Hence the operation may time out later than the given time margin, but never earlier.