[Openmcl-devel] How can I detect a client closed its connection to a listener socket?

Andreas Thiele andreas at atp-media.de
Mon Nov 30 07:00:26 PST 2015


Hi,

 

I wrote the following bit of code:

 

(defvar *test-socket* nil)

 

(defun test-listener ()

  (loop 

     (let ((stream (ccl:accept-connection *test-socket*

 
:stream-args '(:external-format :iso-8859-1))))

       (adt:record :dbg "connect test")

       (loop :unless (ccl:stream-eofp stream) :do (sleep 0.2))

       (adt:record :dbg "disconnect test"))))

 

(defun start-test-listener ()

  (setf *test-socket* (ccl:make-socket :local-port 4010

 
:connect :passive :reuse-address t :keepalive t))

  (ccl:process-run-function "Test Listener" 'test-listener))

 

(defvar *test-stream* nil)

 

(defun connect-test ()

  (ignore-errors

    (setf *test-stream* (ccl:make-socket :remote-host "127.0.0.1"

 
:remote-port 4010))))

 

adt:record just prints to my slime-repl. I start the listener using
start-test-listener connect a client via connect-test. "connect test"
appears within my slime window. I do a (close *test-stream*) but nothing
happens. (ccl:tream-eofp stream) never returns true and thus the loop never
ends and no "disconnect test" can appear. Is there a way to solve this? How
do I detect, the client has closed the connection?

 

Thankful for any hint or help.

 

Best Regards

Andreas Thiele

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20151130/8d01ab50/attachment.htm>


More information about the Openmcl-devel mailing list