[Haskell] Re: [Haskell-cafe] ANNOUNCE: enumerator, an alternative iteratee package

Magnus Therning magnus at therning.org
Sat Aug 21 04:40:44 EDT 2010

On 20/08/10 23:12, John Millikin wrote:
> On Fri, Aug 20, 2010 at 14:58, Magnus Therning <magnus at therning.org> wrote:
>> Indeed.
>> In many protocols it would force the attacker to send well-formed requests
>> though.  I think this is true for many text-based protocols like
>> HTTP.
>> The looping can be handled effectively through hWaitForInput.
>> There are also other reasons for doing non-blocking IO, not least that it
>> makes developing and manual testing a lot nicer.
> I think I'm failing to understand something.
> Using a non-blocking read doesn't change how the iteratees react to
> well- or mal-formed requests. All it does is change the failure
> condition from "blocked indefinitely" to "looping indefinitely".

It changes the timing.  The iteratee will receive the data sooner (when it's
available rather than when the buffer is full).  This means it can fail
*sooner*, in wall-clock time.

> Replacing the hGet with a combination of hWaitForInput /
> hGetNonBlocking would cause a third failure condition, "looping
> indefinitely with periodic blocks". This doesn't seem to be an
> improvement over simply blocking.

It is an improvement when data is trickling in.  In other cases it's no
improvement (besides that it'd be possible have time-outs on a "lower

> Do you have any example code which works well using a non-blocking
> enumerator, but fails with a blocking one?

It's not about failing vs non-failing, it's about time of failure.  An
would be failing after reading a few bytes (the verb of a HTTP request) vs
failing after either reading 4k (which is the buffer size in iteratee, IIRC)
or when the client hangs up.


Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org           Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100821/88d48ffa/signature-0001.bin

More information about the Haskell-Cafe mailing list