anchor.diff:  (in-package :cl-async)
   
   (defclass async-stream (trivial-gray-stream-mixin)
  -  ((socket :accessor stream-socket :initarg :socket :initform nil)))
  -(defclass async-output-stream (fundamental-binary-output-stream async-stream) ())
  -(defclass async-input-stream (fundamental-binary-input-stream async-stream) ())
  -(defclass async-io-stream (async-input-stream async-output-stream) ())
  +  ((socket :accessor stream-socket :initarg :socket :initform nil))
  +  (:documentation "The underlying class for async streams. Wraps a tcp socket class."))
  +(defclass async-output-stream (fundamental-binary-output-stream async-stream) ()
  +  (:documentation "Async output stream."))
  +(defclass async-input-stream (fundamental-binary-input-stream async-stream) ()
  +  (:documentation "Async input stream."))
  +(defclass async-io-stream (async-input-stream async-output-stream) ()
  +  (:documentation "Async stream for both input and output."))
   
   ;; -----------------------------------------------------------------------------
   ;; base stream
   ;; -----------------------------------------------------------------------------
   (defmethod stream-output-type ((stream async-stream))
  +  "This is always a binary stream."
     '(unsigned-byte 8))
   
   (defmethod open-stream-p ((stream async-stream))
  +  "Test the underlying socket to see if this stream is open."
     (let ((socket (stream-socket stream)))
       (not (as:socket-closed-p socket))))
   
   (defmethod close ((stream async-stream) &key abort)
  -  (declare (ignore abort))
  +  "Close the stream. If aborting, attempt to clear out remaining data in the
  +   buffers before closing (is this really needed?)"
  +  (when abort
  +    (when (output-stream-p stream)
  +      (clear-output stream))
  +    (when (input-stream-p stream)
  +      (clear-input stream)))
     (as:close-socket (stream-socket stream)))
   
   ;; -----------------------------------------------------------------------------
   ;; output stream
   ;; -----------------------------------------------------------------------------
   (defmethod stream-clear-output ((stream async-output-stream))
  +  "Attempt to clear the output buffer of an output stream."
     (when (open-stream-p stream)
       (let* ((socket (stream-socket stream))
              (bev (socket-c socket))
  
positive.code: ;; input stream
  ;; -----------------------------------------------------------------------------
  (defmethod stream-clear-input ((stream async-input-stream))
    (when (open-stream-p stream)
      (let* ((socket (stream-socket stream))
             (bev (socket-c socket))
  
negative.code:         (le:evbuffer-drain bev-input 9999999)))))
  
  (defmethod stream-read-byte ((stream async-input-stream))
    "Read one byte from the underlying socket."
    (let ((byte (as::read-bytes-from-socket (stream-socket stream) 1)))
      (if byte
          (aref byte 0)
          :eof)))
  
  (defmethod stream-read-sequence ((stream async-input-stream) sequence start end &key)
    "Attempt to read a sequence of bytes from the underlying socket."
    (let ((seq (as::read-bytes-from-socket (stream-socket stream) (- end start))))
      (if seq
          (progn
  