[usocket-cvs] r222 - in usocket/trunk: . backend

ehuelsmann at common-lisp.net ehuelsmann at common-lisp.net
Tue Apr 3 20:13:41 UTC 2007


Author: ehuelsmann
Date: Tue Apr  3 16:13:38 2007
New Revision: 222

Modified:
   usocket/trunk/backend/allegro.lisp
   usocket/trunk/backend/armedbear.lisp
   usocket/trunk/backend/clisp.lisp
   usocket/trunk/backend/cmucl.lisp
   usocket/trunk/backend/lispworks.lisp
   usocket/trunk/backend/openmcl.lisp
   usocket/trunk/backend/sbcl.lisp
   usocket/trunk/backend/scl.lisp
   usocket/trunk/usocket.lisp
Log:
Support the more common reuse-address option for listening sockets.

Modified: usocket/trunk/backend/allegro.lisp
==============================================================================
--- usocket/trunk/backend/allegro.lisp	(original)
+++ usocket/trunk/backend/allegro.lisp	Tue Apr  3 16:13:38 2007
@@ -60,11 +60,13 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
   ;; Allegro and OpenMCL socket interfaces bear very strong resemblence
   ;; whatever you change here, change it also for OpenMCL
-  (let ((sock (with-mapped-conditions ()
+  (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+         (sock (with-mapped-conditions ()
                  (apply #'socket:make-socket
                         (append (list :connect :passive
                                       :reuse-address reuseaddress

Modified: usocket/trunk/backend/armedbear.lisp
==============================================================================
--- usocket/trunk/backend/armedbear.lisp	(original)
+++ usocket/trunk/backend/armedbear.lisp	Tue Apr  3 16:13:38 2007
@@ -33,9 +33,11 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
-  (let* ((sock-addr (jnew-call ("java.net.InetSocketAddress"
+  (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+         (sock-addr (jnew-call ("java.net.InetSocketAddress"
                                 "java.lang.String" "int")
                                (host-to-hostname host) port))
          (sock (jnew-call ("java.net.ServerSocket"))))

Modified: usocket/trunk/backend/clisp.lisp
==============================================================================
--- usocket/trunk/backend/clisp.lisp	(original)
+++ usocket/trunk/backend/clisp.lisp	Tue Apr  3 16:13:38 2007
@@ -51,11 +51,13 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
   ;; clisp 2.39 sets SO_REUSEADDRESS to 1 by default; no need to
-  ;; to explicitly turn it on.
-   (let ((sock (apply #'socket:socket-server
+  ;; to explicitly turn it on; unfortunately, there's no way to turn it off...
+  (declare (ignore reuseaddress reuse-address))
+  (let ((sock (apply #'socket:socket-server
                      (append (list port
                                    :backlog backlog)
                              (when (ip/= host *wildcard-host*)

Modified: usocket/trunk/backend/cmucl.lisp
==============================================================================
--- usocket/trunk/backend/cmucl.lisp	(original)
+++ usocket/trunk/backend/cmucl.lisp	Tue Apr  3 16:13:38 2007
@@ -72,15 +72,17 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
- (let ((server-sock (apply #'ext:create-inet-listener
-                           (append (list port :stream
-                                         :backlog backlog
-                                         :reuse-address reuseaddress)
-                                   (when (ip/= host *wildcard-host*)
-                                     (list :host
-                                           (host-to-hbo host)))))))
+ (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+        (server-sock (apply #'ext:create-inet-listener
+                            (append (list port :stream
+                                          :backlog backlog
+                                          :reuse-address reuseaddress)
+                                    (when (ip/= host *wildcard-host*)
+                                      (list :host
+                                            (host-to-hbo host)))))))
    (make-stream-server-socket server-sock :element-type element-type)))
 
 (defmethod socket-accept ((usocket stream-server-usocket) &key element-type)

Modified: usocket/trunk/backend/lispworks.lisp
==============================================================================
--- usocket/trunk/backend/lispworks.lisp	(original)
+++ usocket/trunk/backend/lispworks.lisp	Tue Apr  3 16:13:38 2007
@@ -58,9 +58,11 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'base-char))
-  (let* ((comm::*use_so_reuseaddr* reuseaddress)
+  (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+         (comm::*use_so_reuseaddr* reuseaddress)
          (hostname (host-to-hostname host))
          (sock (with-mapped-conditions ()
                   #-lispworks4.1 (comm::create-tcp-socket-for-service

Modified: usocket/trunk/backend/openmcl.lisp
==============================================================================
--- usocket/trunk/backend/openmcl.lisp	(original)
+++ usocket/trunk/backend/openmcl.lisp	Tue Apr  3 16:13:38 2007
@@ -56,9 +56,11 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
-  (let* ((sock (apply #'openmcl-socket:make-socket
+  (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+         (sock (apply #'openmcl-socket:make-socket
                       (append (list :connect :passive
                                     :reuse-address reuseaddress
                                     :local-port port

Modified: usocket/trunk/backend/sbcl.lisp
==============================================================================
--- usocket/trunk/backend/sbcl.lisp	(original)
+++ usocket/trunk/backend/sbcl.lisp	Tue Apr  3 16:13:38 2007
@@ -84,9 +84,11 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
-  (let* ((ip (host-to-vector-quad host))
+  (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+         (ip (host-to-vector-quad host))
          (sock (make-instance 'sb-bsd-sockets:inet-socket
                               :type :stream :protocol :tcp)))
     (setf (sb-bsd-sockets:sockopt-reuse-address sock) reuseaddress)

Modified: usocket/trunk/backend/scl.lisp
==============================================================================
--- usocket/trunk/backend/scl.lisp	(original)
+++ usocket/trunk/backend/scl.lisp	Tue Apr  3 16:13:38 2007
@@ -43,15 +43,17 @@
 
 (defun socket-listen (host port
                            &key reuseaddress
+                           (reuse-address nil reuse-address-supplied-p)
                            (backlog 5)
                            (element-type 'character))
-  (let* ((host (if (ip= host *wildcard-host*)
-                  0
-                  (host-to-hbo host)))
-        (server-sock (ext:create-inet-listener port :stream
-                                               :host host
-                                               :reuse-address reuseaddress
-                                               :backlog backlog)))
+  (let* ((reuseaddress (if reuse-address-supplied-p reuse-address reuseaddress))
+         (host (if (ip= host *wildcard-host*)
+                   0
+                 (host-to-hbo host)))
+         (server-sock (ext:create-inet-listener port :stream
+                                                :host host
+                                                :reuse-address reuseaddress
+                                                :backlog backlog)))
    (make-stream-server-socket server-sock :element-type element-type)))
 
 (defmethod socket-accept ((usocket stream-server-usocket) &key element-type)

Modified: usocket/trunk/usocket.lisp
==============================================================================
--- usocket/trunk/usocket.lisp	(original)
+++ usocket/trunk/usocket.lisp	Tue Apr  3 16:13:38 2007
@@ -304,9 +304,11 @@
 
 Returns an object of type `stream-server-usocket'.
 
-`reuseaddress' and `backlog' are advisory parameters for setting socket
+`reuse-address' and `backlog' are advisory parameters for setting socket
 options at creation time. `element-type' is the element type of the
-streams to be created by `socket-accept'.
+streams to be created by `socket-accept'.  `reuseaddress' is supported for
+backward compatibility (but deprecated); when both `reuseaddress' and
+`reuse-address' have been specified, the latter takes precedence.
 ")
 
 ;; Documentation for the function



More information about the usocket-cvs mailing list