anchor.diff:      (encode-int *size-delim* :little 0)
       (encode-int (length buffer) :big 4)
       (encode-int *data-delim* :little 8)
  -    (write-bytes-dammit size-buf s)
  -    (write-bytes-dammit buffer s)))
  +    (write-sequence size-buf s)
  +    (write-sequence buffer s)))
  +    ;;(write-bytes-dammit size-buf s)
  +    ;;(write-bytes-dammit buffer s)))
   
   
   (defun ach-status (channel)
  
positive.code:                "Invalid size delimiter: ~A" (subseq size-buf 8))
      (let* ((size (decode-uint size-buf :big 4))
             ;;(buffer (make-array size :element-type '(unsigned-byte 8))))
             (buffer (make-octet-vector size)))
        ;(read-bytes-dammit buffer s)
        (read-sequence buffer s)
        buffer)))
  
negative.code:   channel)
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; CONTINUOUS READING ;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  ;;; maintain a background thread that will continuously read the
  ;;; channel
  
  (defun make-listener (channel-name &key last)
    (let ((lock (sb-thread:make-mutex))
          (buffer nil)
          (continue t))
      (let ((thread  ; start the listening thread
             (sb-thread:make-thread
              (lambda () (let ((channel (ach-open channel-name
                                             :direction :input :last last)))
                      (unwind-protect (loop
                                         while continue
                                         for tmp-buffer = (ach-read channel)
                                         do (sb-thread:with-mutex (lock)
                                              (setq buffer tmp-buffer)))
                        (ach-close channel))))
              :name (concatenate 'string "ach-listener-" channel-name))))
        ;; return a closure to get the next buffer or terminate the listener
        (lambda (&key terminate)
          (if terminate
              ;; stop the listener
              (progn
                ;; FIXME: be more robust
                (setq continue nil)
                (sb-thread:join-thread thread))
              ;; get the buffer
              (progn
                (sb-thread:with-mutex (lock)
                  (copy-seq buffer))))))))
  
  
  