anchor.diff:  	    (ccl::stream-io-error stream (- error) "read"))))))
   
   #+sbcl
  -(defun input-wait (stream fd deadline)
  +(defun input-wait (stream fd deadline &optional read-timeout)
     (declare (ignore stream))
     (let ((timeout
  +	 ;;
  +	 ;; if deadline is nil, then write-timeout is looked to as the timeout which could also be nil
  +	 ;;
   	 ;; *deadline* is handled by wait-until-fd-usable automatically,
   	 ;; but we need to turn a user-specified deadline into a timeout
  -	 (when deadline
  -	   (/ (- deadline (get-internal-real-time))
  -	      internal-time-units-per-second))))
  -    (sb-sys:wait-until-fd-usable fd :input timeout)))
  +	 (if deadline
  +	     (/ (- deadline (get-internal-real-time))
  +		internal-time-units-per-second)
  +	     read-timeout)))
  +    (unless (sb-sys:wait-until-fd-usable fd :input timeout)
  +      (error (make-condition 'ssl-timeout))))) 
   
   #-(or clozure-common-lisp sbcl)
   (defun input-wait (stream fd deadline)
  
positive.code: (defconstant +SSL_CTRL_SET_SESS_CACHE_MODE+ 44)
  (defconstant +SSL_CTRL_MODE+ 33)
  
  (defconstant +SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER+ 2)
  
  ;;; Misc
  ;;;
  
negative.code:   (buf :pointer)
    (num :int))
  
  ;;RSA *RSA_generate_key(int num, unsigned long e,
  ;;    void (*callback)(int,int,void *), void *cb_arg);
  (cffi:defcfun ("RSA_generate_key" rsa-generate-key)
      :pointer
    (num :int)
    (e :unsigned-long) 
    (callback :pointer)
    (opt :pointer))
  
  ;;void RSA_free(RSA *rsa);
  ;;
  (cffi:defcfun ("RSA_free" rsa-free)
      :void
    (rsa :pointer))
  
  ;void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
  ;            RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength));
  (cffi:defcfun ("SSL_CTX_set_tmp_rsa_callback" ssl-ctx-set-tmp-rsa-callback)
      :pointer
    (ctx :pointer)
    (callback :pointer))
  
  ;static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
  
  (cffi:defcallback need-tmp-rsa-callback :pointer ((ssl :pointer) (export-p :int) (key-length :int))
    (declare (ignore ssl export-p))
  					;
  					;blindly assume 512 bit key is needed
  					;
    (cond ((= key-length 512)
  	 (progn
  	   (unless *tmp-rsa-key-512* (setf *tmp-rsa-key-512* (rsa-generate-key 512 +RSA_F4+ (cffi:null-pointer) (cffi:null-pointer))))
  		      *tmp-rsa-key-512*)
  	 t
  	 (progn
  	   (unless *tmp-rsa-key-1024* (setf *tmp-rsa-key-1024* (rsa-generate-key 1024 +RSA_F4+ (cffi:null-pointer) (cffi:null-pointer))))
  	   *tmp-rsa-key-1024*))))
  
  ;;; Funcall wrapper
  ;;;
  (defvar *socket*)
  