[usocket-cvs] r207 - usocket/trunk/backend

ehuelsmann at common-lisp.net ehuelsmann at common-lisp.net
Fri Mar 2 21:25:13 UTC 2007


Author: ehuelsmann
Date: Fri Mar  2 16:25:12 2007
New Revision: 207

Modified:
   usocket/trunk/backend/allegro.lisp
   usocket/trunk/backend/armedbear.lisp
   usocket/trunk/backend/clisp.lisp
   usocket/trunk/backend/lispworks.lisp
   usocket/trunk/backend/openmcl.lisp
   usocket/trunk/backend/sbcl.lisp
   usocket/trunk/backend/scl.lisp
Log:
Fix closing of (stream) sockets (and comment).

Modified: usocket/trunk/backend/allegro.lisp
==============================================================================
--- usocket/trunk/backend/allegro.lisp	(original)
+++ usocket/trunk/backend/allegro.lisp	Fri Mar  2 16:25:12 2007
@@ -50,6 +50,9 @@
                                  :format (to-format element-type))))
     (make-stream-socket :socket socket :stream socket)))
 
+
+;; One socket close method is sufficient,
+;; because socket-streams are also sockets.
 (defmethod socket-close ((usocket usocket))
   "Close socket."
   (with-mapped-conditions (usocket)

Modified: usocket/trunk/backend/armedbear.lisp
==============================================================================
--- usocket/trunk/backend/armedbear.lisp	(original)
+++ usocket/trunk/backend/armedbear.lisp	Fri Mar  2 16:25:12 2007
@@ -66,6 +66,12 @@
   (with-mapped-conditions (usocket)
     (ext:socket-close (socket usocket))))
 
+;; Socket streams are different objects than
+;; socket streams. Closing the stream flushes
+;; its buffers *and* closes the socket.
+(defmethod socket-close ((usocket stream-usocket))
+  (with-mapped-conditions (usocket)
+    (close (socket-stream usocket))))
 
 (defmethod get-local-address ((usocket usocket))
   (dotted-quad-to-vector-quad (ext:socket-local-address (socket usocket))))

Modified: usocket/trunk/backend/clisp.lisp
==============================================================================
--- usocket/trunk/backend/clisp.lisp	(original)
+++ usocket/trunk/backend/clisp.lisp	Fri Mar  2 16:25:12 2007
@@ -70,6 +70,9 @@
     (make-stream-socket :socket stream
                         :stream stream)))
 
+;; Only one close method required:
+;; sockets and their associated streams
+;; are the same object
 (defmethod socket-close ((usocket usocket))
   "Close socket."
   (with-mapped-conditions (usocket)

Modified: usocket/trunk/backend/lispworks.lisp
==============================================================================
--- usocket/trunk/backend/lispworks.lisp	(original)
+++ usocket/trunk/backend/lispworks.lisp	Fri Mar  2 16:25:12 2007
@@ -76,11 +76,14 @@
                                                   (element-type usocket)))))
     (make-stream-socket :socket sock :stream stream)))
 
+;; Sockets and their streams are different objects
+;; close the stream in order to make sure buffers
+;; are correctly flushed and the socket closed.
 (defmethod socket-close ((usocket stream-usocket))
   "Close socket."
   (close (socket-stream usocket)))
 
-(defmethod socket-close ((usocket stream-server-usocket))
+(defmethod socket-close ((usocket usocket))
   (with-mapped-conditions (usocket)
      (comm::close-socket (socket usocket))))
 

Modified: usocket/trunk/backend/openmcl.lisp
==============================================================================
--- usocket/trunk/backend/openmcl.lisp	(original)
+++ usocket/trunk/backend/openmcl.lisp	Fri Mar  2 16:25:12 2007
@@ -73,6 +73,9 @@
   (let ((sock (openmcl-socket:accept-connection (socket usocket))))
     (make-stream-socket :socket sock :stream sock)))
 
+;; One close method is sufficient because sockets
+;; and their associated objects are represented
+;; by the same object.
 (defmethod socket-close ((usocket usocket))
   (with-mapped-conditions (usocket)
     (close (socket usocket))))

Modified: usocket/trunk/backend/sbcl.lisp
==============================================================================
--- usocket/trunk/backend/sbcl.lisp	(original)
+++ usocket/trunk/backend/sbcl.lisp	Fri Mar  2 16:25:12 2007
@@ -102,10 +102,17 @@
                                  :element-type (or element-type
                                                    (element-type socket))))))
 
+;; Sockets and their associated streams are modelled as
+;; different objects. Be sure to close the stream (which
+;; closes the socket too) when closing a stream-socket.
 (defmethod socket-close ((usocket usocket))
   (with-mapped-conditions (usocket)
     (sb-bsd-sockets:socket-close (socket usocket))))
 
+(defmethod socket-close ((usocket stream-usocket))
+  (with-mapped-conditions (usocket)
+    (close (socket-stream usocket))))
+
 (defmethod get-local-name ((usocket usocket))
   (sb-bsd-sockets:socket-name (socket usocket)))
 

Modified: usocket/trunk/backend/scl.lisp
==============================================================================
--- usocket/trunk/backend/scl.lisp	(original)
+++ usocket/trunk/backend/scl.lisp	Fri Mar  2 16:25:12 2007
@@ -62,11 +62,20 @@
                                      :buffering :full)))
     (make-stream-socket :socket sock :stream stream)))
 
+;; Sockets and their associated streams are modelled as
+;; different objects. Be sure to close the socket stream
+;; when closing stream-sockets; it makes sure buffers
+;; are flushed and the socket is closed correctly afterwards.
 (defmethod socket-close ((usocket usocket))
   "Close socket."
   (with-mapped-conditions (usocket)
     (ext:close-socket (socket usocket))))
 
+(defmethod socket-close ((usocket stream-usocket))
+  "Close socket."
+  (with-mapped-conditions (usocket)
+    (close (socket-stream usocket))))
+
 (defmethod get-local-name ((usocket usocket))
   (multiple-value-bind (address port)
       (with-mapped-conditions (usocket)



More information about the usocket-cvs mailing list