On 2009 Feb 27, at 4:25, Colin Paul Adams wrote:
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.

Johan> I'm not sure I agree. I think using exceptions in this case is fine as Johan> loosing the connection is indeed an exceptional condition and the best Johan> thing a program can do in this case is probably to abort processing of
Johan> the disconnected client.

I guess this depends upon how exceptional you want an exception to be.

To my mind, a lost connection is a fairly normal condition (FAR to
normal for my teleworking situation :-( ). That is, I would expect
the exception to occur rather than not, during one run of a
program. On that basis, I would suggest Nothing is better than an
exception.

Actually, thinking about this, ECONNRESET can be a normal end-of- connection for TCP, but for UDP should never happen (on recv(); on send() it is surely an exception). But at the same time, if you're using recv() with TCP you are probably not working with a higher level protocol that simply shuts down the connection when it's done: it's more of a stream-oriented behavior, and the stream-oriented read() handles it as such.

That said I have heard of cases where recv() is used for stream protocols for efficiency reasons. I don't know if the efficiency argument relates to anything newer than a PDP11 or VAX 750, though....

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university    KF8NH


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to