2009/2/27 Brandon S. Allbery KF8NH <[email protected]>: > On 2009 Feb 26, at 23:41, Achim Schneider wrote: >> "Brandon S. Allbery KF8NH" <[email protected]> wrote: >>> On 2009 Feb 26, at 16:45, Johan Tibell wrote: >>> Anyway, the reason recv doesn't return 0 is that if you have a >>> datagram socket, a zero-length recv is valid and doesn't mean EOF. >>> >> My man page says a retval of 0 means that "the peer has performed an >> orderly shutdown", which, in the UDP case, means that it has send a >> complete datagram... no mention of EOF. A true EOF in the sense of "no >> more data will be received" would mean unbinding the socket. > > Right. Just have to realize that a zero-length datagram packet is possible > and even meaningful, so 0 isn't available as an EOF flag.
If this is the case then the Network.Socket module is broken when used for UDP as it throw an exception on receiving a valid message. > Anyway, the POSIX spec indicates the EOF condition as return -1 with errno > == ECONNRESET; this should not be taken as anything but the limited > expressiveness of a C-based API. We should map this return to Nothing. I'm not sure I agree. I think using exceptions in this case is fine as loosing the connection is indeed an exceptional condition and the best thing a program can do in this case is probably to abort processing of the disconnected client. Cheers, Johan _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
