[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Reading from a process

Subject: Re: [Haskell-cafe] Reading from a process
From: Jason Dusek
Date: Wed, 16 Dec 2009 14:25:02 -0800
2009/12/16 Mitar <[email protected]>:
> The problem is that I do not like this approach. And it does not look
> nice. For example I am reading byte per byte and appending it to the
> end. Then the problem is that if process is sending garbage faster
> then Haskell can consume it Haskell stays in slurpInput function and
> never gets to readData where it would found out that there is garbage
> coming in. I could use hGetBufNonBlocking? But it would still not
> solve garbage problem.

  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`.

> So is there some better way to do it?

  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.

Jason Dusek
Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>