Author: ehuelsmann
Date: Fri Mar 2 17:08:14 2007
New Revision: 209
Modified:
usocket/branches/0.3.x/backend/allegro.lisp
usocket/branches/0.3.x/backend/armedbear.lisp
usocket/branches/0.3.x/backend/clisp.lisp
usocket/branches/0.3.x/backend/cmucl.lisp
usocket/branches/0.3.x/backend/lispworks.lisp
usocket/branches/0.3.x/backend/openmcl.lisp
usocket/branches/0.3.x/backend/sbcl.lisp
usocket/branches/0.3.x/backend/scl.lisp
Log:
Merge r206:208 from trunk: add comments and fix (stream) socket closing.
Modified: usocket/branches/0.3.x/backend/allegro.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/allegro.lisp (original)
+++ usocket/branches/0.3.x/backend/allegro.lisp Fri Mar 2 17:08:14 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/branches/0.3.x/backend/armedbear.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/armedbear.lisp (original)
+++ usocket/branches/0.3.x/backend/armedbear.lisp Fri Mar 2 17:08:14 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/branches/0.3.x/backend/clisp.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/clisp.lisp (original)
+++ usocket/branches/0.3.x/backend/clisp.lisp Fri Mar 2 17:08:14 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/branches/0.3.x/backend/cmucl.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/cmucl.lisp (original)
+++ usocket/branches/0.3.x/backend/cmucl.lisp Fri Mar 2 17:08:14 2007
@@ -91,11 +91,19 @@
:buffering :full)))
(make-stream-socket :socket sock :stream stream)))
-(defmethod socket-close ((usocket usocket))
+;; Sockets and socket streams are represented
+;; by different objects. Be sure to close the
+;; socket stream when closing a stream socket.
+(defmethod socket-close ((usocket stream-usocket))
"Close socket."
(with-mapped-conditions (usocket)
(close (socket-stream usocket))))
+(defmethod socket-close ((usocket usocket))
+ "Close socket."
+ (with-mapped-conditions (usocket)
+ (ext:close-socket (socket usocket))))
+
(defmethod get-local-name ((usocket usocket))
(multiple-value-bind
(address port)
Modified: usocket/branches/0.3.x/backend/lispworks.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/lispworks.lisp (original)
+++ usocket/branches/0.3.x/backend/lispworks.lisp Fri Mar 2 17:08:14 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/branches/0.3.x/backend/openmcl.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/openmcl.lisp (original)
+++ usocket/branches/0.3.x/backend/openmcl.lisp Fri Mar 2 17:08:14 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/branches/0.3.x/backend/sbcl.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/sbcl.lisp (original)
+++ usocket/branches/0.3.x/backend/sbcl.lisp Fri Mar 2 17:08:14 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/branches/0.3.x/backend/scl.lisp
==============================================================================
--- usocket/branches/0.3.x/backend/scl.lisp (original)
+++ usocket/branches/0.3.x/backend/scl.lisp Fri Mar 2 17:08:14 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)