John Goerzen writes:
> Which arguably is not what one would expect recv to do,
> and in any case is undocumented at
> http://www.haskell.org/ghc/docs/latest/html/libraries/network/Network.Socket.html#v%3Arecv
Someone correct me if I am wrong, but I think that _all_ I/O
functions may throw an EOF exception -- not just recv. I
have found the following wrapper to be the simplest solution
to dealing with that:
-- |Return 'Nothing' if the given computation throws an
-- 'isEOFError' exception.
handleEOF :: IO a -> IO (Maybe a)
handleEOF f =
catchJust ioErrors
(fmap Just f)
(\e -> if isEOFError e then return Nothing else ioError e)
Peter
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe