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

Ian Lynagh igloo at earth.li
Sat Apr 7 16:25:42 EDT 2007


On Fri, Apr 06, 2007 at 01:44:01PM -0600, Scott Bell wrote:
> 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)

Have you got a complete (but preferably small) program showing the
problem?


Thanks
Ian



More information about the Haskell-Cafe mailing list