[Haskell-cafe] Re: `Expect'-like lazy reading/Parsec matching on TCP sockets

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Apr 6 15:53:40 EDT 2007

Hello Scott,

Friday, April 6, 2007, 11:44:01 PM, you wrote:

you should write compiler version and OS for such problems. if it's
6.6 and Win, try to upgrade to current STABLE build: smth like
but newer (this one is dec 12 build)

I/O in Windows threaded RTS was fixed after initial 6.6 release and
afaik hWaitForInput should work better now. alternatively, you can try
with hand-made timeout solution

> Ooops! It seems that this doesn't behave well with a -threaded
> RTS. I get an EOF on handles that I know for a fact shouldn't
> be receiving them. It still works well without -threaded, but
> does anyone know why I'm getting this behavior?

> hGetContentsTimeout :: Handle -> Int -> IO String
> hGetContentsTimeout h t = do
>   hSetBuffering stdin NoBuffering
>   ready <- hWaitForInput h t
>   if (not ready) then return []
>     else do
>       c <- hGetChar h
>       s <- unsafeInterleaveIO (hGetContentsTimeout h t)
>       return (c:s)

> (I did add EOF checking, but all that did was return the end of the list earlier than I wanted)


Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list