diff --git a/backend/lispworks.lisp b/backend/lispworks.lisp index acfe421..5deff23 100644 --- a/backend/lispworks.lisp +++ b/backend/lispworks.lisp @@ -384,9 +384,8 @@ (error "cannot create socket")))))) (defun socket-connect (host port &key (protocol :stream) (element-type 'base-char) - timeout deadline (nodelay t nodelay-specified) + timeout deadline (nodelay t) local-host local-port) - ;; What's the meaning of this keyword? (when deadline (unimplemented 'deadline 'socket-connect)) @@ -395,11 +394,6 @@ (when timeout (unsupported 'timeout 'socket-connect :minimum "LispWorks 4.4.5")) - #+(or lispworks4 lispworks5.0) ; < 5.1 - (when (and nodelay-specified - (not (eq nodelay :if-supported))) - (unsupported 'nodelay 'socket-connect :minimum "LispWorks 5.1")) - #+lispworks4 (when local-host (unsupported 'local-host 'socket-connect :minimum "LispWorks 5.0")) @@ -411,7 +405,7 @@ (:stream (let ((hostname (host-to-hostname host)) (stream)) - (setf stream + (setq stream (with-mapped-conditions () (comm:open-tcp-stream hostname port :element-type element-type @@ -425,6 +419,15 @@ #-(or lispworks4 lispworks5.0) ; >= 5.1 #-(or lispworks4 lispworks5.0) :nodelay nodelay))) + + ;; Then handle `nodelay' separately for older versions <= 5.0 + #+(or lispworks4 lispworks5.0) + (when (and stream nodelay) + (#+lispworks4 set-socket-tcp-nodelay + #+lispworks5.0 comm::set-socket-tcp-nodelay + (comm:socket-stream-socket stream) + (bool->int nodelay))) ; ":if-supported" maps to 1 too. + (if stream (make-stream-socket :socket (comm:socket-stream-socket stream) :stream stream) diff --git a/option.lisp b/option.lisp index 28ad1d0..b775e29 100644 --- a/option.lisp +++ b/option.lisp @@ -4,11 +4,6 @@ (in-package :usocket) -;;; Small utility functions -(declaim (inline bool->int) (inline int->bool)) -(defun bool->int (bool) (if bool 1 0)) -(defun int->bool (int) (= 1 int)) - ;;; Interface definition (defgeneric socket-option (socket option &key) diff --git a/usocket.lisp b/usocket.lisp index f93573d..e429c48 100644 --- a/usocket.lisp +++ b/usocket.lisp @@ -683,3 +683,10 @@ 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. ") + +;;; Small utility functions mapping true/false to 1/0, moved here from option.lisp + +(proclaim '(inline bool->int int->bool)) + +(defun bool->int (bool) (if bool 1 0)) +(defun int->bool (int) (= 1 int))