[Haskell-cafe] ANNOUNCE: enumerator 0.4.8

John Millikin jmillikin at gmail.com
Sun Mar 27 05:50:28 CEST 2011


Hello Ertugrul Söylemez,

Good idea -- I've added an ``enumSocketTimed`` and ``iterSocketTimed`` to 
the network-enumerator package at < 
http://hackage.haskell.org/package/network-enumerator >. ``enumSocketTimed`` 
is equivalent to your ``enumHandleTimeout``, but instead of Handle uses the 
more efficient Socket type.

For setting a global timeout on an entire session, it's better to wrap the 
``run_`` call with ``System.Timeout.timeout`` -- this is more efficient than 
testing the time on every chunk, and does not require a specialised 
enumerator.

The signatures/docs are:

--------------------------------------------------------

-- | Enumerate binary data from a 'Socket', using 'recv'. The socket must
-- be connected.
--
-- The buffer size should be a small power of 2, such as 4096.
--
-- If any call to 'recv' takes longer than the timeout, 'enumSocketTimed'
-- will throw an error. To add a timeout for the entire session, wrap the
-- call to 'E.run' in 'timeout'.
--
-- Since: 0.1.2
enumSocketTimed :: MonadIO m
                => Integer -- ^ Buffer size     
                -> Integer -- ^ Timeout, in microseconds
                -> S.Socket    
                -> E.Enumerator B.ByteString m b

-- | Write data to a 'S.Socket', using 'sendMany'. The socket must be 
connected.
--
-- If any call to 'sendMany' takes longer than the timeout, 
'iterSocketTimed'
-- will throw an error. To add a timeout for the entire session, wrap the
-- call to 'E.run' in 'timeout'.
--
-- Since: 0.1.2
iterSocketTimed :: MonadIO m
                => Integer -- ^ Timeout, in microseconds
                -> S.Socket
                -> E.Iteratee B.ByteString m ()

--------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110326/be440460/attachment.htm>


More information about the Haskell-Cafe mailing list