[Haskell-cafe] Reading from a process

Mitar mmitar at gmail.com
Wed Dec 16 17:36:49 EST 2009


On Wed, Dec 16, 2009 at 11:25 PM, Jason Dusek <jason.dusek at gmail.com> wrote:
>  The what is a solid, terminating criterion for garbage? How do
>  you know this stream of bytes is no good or has gone as far as
>  you can allow it to go? Use that criterion in `slurpInput`.

Criterion for garbage is that it is not readable with "read" and that
not because there would be not enough data available. It seems that I
will need to do buffer filling and reading at the same time. I was
hoping I could split this in two functions.

>  I urge you to reconsider your approach for message delimiting.
>  Why use the `hReady` signal as the clue? Seems like a race
>  condition waiting to happen. Maybe terminate them with a
>  Haskell comment, like `-- EOT`. Since your message always
>  comes wrapped in a list, you could just use the square
>  brackets to tell you when you're done.

I am not using hReady signal as delimiter. This is just to have some
robustness for example if processes will communicate over network and
there will be delays. So I am just trying to pick enough bytes
together for "read" to succeed. And I do have upper limit on the
message defined.


More information about the Haskell-Cafe mailing list