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

Scott Bell sebell at gmail.com
Fri Apr 6 15:44:01 EDT 2007


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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070406/aeb83051/attachment.htm


More information about the Haskell-Cafe mailing list