Subject: [clisp-list] socket problem: handling unexpected client disconnects

From: "Darken, Chris USA" <[email-masked]>
Date: Sun Sep 7 06:48:04 2003

I have a CLISP program (CLISP 2.31 under WinXP) that sends characters to a client program over a socket.  My problem is that when the connection is lost (e.g. because the client program receiving the characters unexpectedly closes the connection on its end), my program exits either in a call to socket-status or in a write-char to the socket with an error like:
 
*** - Winsock error 10054 (ECONNRESET): Connection reset by peer
 
I don't know much about error handling under lisp, but I can't see how to catch this error.  I've searched the mailing list archive and haven't found a solution.
 
Can anyone tell me how my program could tolerate unexpected client disconnects without exiting?
 
Chris

---

From: Sam Steingold <[email-masked]>
Date: Wed Sep 10 15:05:08 2003

>* Darken, Chris USA <[email-masked]> [2003-09-07 06:47:36 -0700]:
>
> I have a CLISP program (CLISP 2.31 under WinXP) that sends characters
> to a client program over a socket.  My problem is that when the
> connection is lost (e.g. because the client program receiving the
> characters unexpectedly closes the connection on its end), my program
> exits either in a call to socket-status or in a write-char to the
> socket with an error like:
>  
> I don't know much about error handling under lisp, but I can't see how
> to catch this error.  I've searched the mailing list archive and
> haven't found a solution.
>  

I do not observe this with the native (mingw) port:

[3]> (setq s (ext:socket-server))
#<SOCKET-SERVER 0.0.0.0:4686>
[4]> (setq l (ext:socket-accept s))         ; telnet localhost 4686
#<IO UNBUFFERED SOCKET-STREAM CHARACTER 0.0.0.0:4686>
[5]> (ext:socket-status l)
:OUTPUT ;
1
[6]> (ext:socket-status l)                   ; close telnet
:APPEND ;
1
[7]>

i.e., :APPEND means :EOF on read (connection closed)

are you using cygwin?

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
usually: can't pay ==> don't buy. software: can't buy ==> don't pay