[Haskell-cafe] Coming up with a better API for Network.Socket.recv
johan.tibell at gmail.com
Thu Feb 26 16:45:47 EST 2009
I find it quite inconvenient to use the `recv` function in
Network.Socket as it throws an exception when reaching EOF and there's
no way to check whether EOF has been reached before calling `recv`.
This means that all calls to `recv` needs to be wrapped in an
exception handler. I've been thinking about changing the version of
`recv` that's included in the network-bytestring library  so it
behaves differently from the one in the network library. Before I do
so I thought I should see if we can reach a consensus on what a nicer
definition of `recv` would look like. My current thinking is that it
would mimic what C/Python/Java does and return a zero length
ByteString when EOF is reached.
I'm also interested in understanding the reasons behind the design of
the `recv` function in the network library. More generally, I'm
interested in discussing the pros and cons of the current Haskell I/O
library design where the different read functions throw EOF exceptions
and you have to call e.g. hIsEOF before reading from a Handle.
More information about the Haskell-Cafe