
19 Feb
2005
19 Feb
'05
4:55 a.m.
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...
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