anchor.diff:    (or *event-base*
         (error "Operation not supported outside of the scope of WITH-EVENT-LOOP.")))
   
  +(defun socket-enqueue (sequence socket)
  +  (enqueue sequence (socket-write-queue socket))
  +  (start-writes socket))
  +
   ;;; Gray streams implementation
   (defmethod stream-write-sequence ((socket socket) sequence start end &key)
  -  (enqueue (subseq sequence (or start 0) (or end (length sequence))) (socket-write-queue socket)))
  +  (socket-enqueue (subseq sequence (or start 0) (or end (length sequence)))
  +                  socket))
   (defmethod stream-line-column ((socket socket))
     ;; TODO
     0)
   (defmethod stream-write-char ((socket socket) character)
     ;; TODO - Meh. Maybe a buffer for very short messages or something?
  -  (enqueue (make-string 1 :initial-element character) (socket-write-queue socket)))
  +  (socket-enqueue (make-string 1 :initial-element character) socket))
   (defmethod stream-write-byte ((socket socket) byte)
  -  (enqueue (make-array 1 :element-type 'flex:octet :initial-element byte) (socket-write-queue socket)))
  +  (socket-enqueue (make-array 1 :element-type 'flex:octet :initial-element byte) socket))
   (defmethod stream-write-string ((socket socket) string &optional start end)
     (stream-write-sequence socket string start end))
   (defmethod close ((socket socket) &key abort)
     (when-let (evbase (and (slot-boundp socket 'internal-socket)
                            (socket-event-base socket)))
  -    (iolib:remove-fd-handlers evbase
  -                              (iolib:socket-os-fd (socket-internal-socket socket))
  -                              :read t :error t)
  +    (socket-pause socket)
       (cond (abort
              (finish-close socket))
             (t
  
positive.code:                                          (content->buffer socket content))
            (socket-write-buffer-offset socket) 0)))
  
  (defun start-writes (socket &aux (driver (socket-driver socket)))
    (iolib:set-io-handler
     (socket-event-base socket) (iolib:socket-os-fd (socket-internal-socket socket))
     :write
     (lambda (&rest ig)
       (declare (ignore ig))
       (loop
          (ensure-write-buffer socket)
          (when (socket-write-buffer socket)
            ;; TODO - the errors are mostly there for my own reference.
            (handler-bind (((or iolib:socket-connection-reset-error
                                isys:ewouldblock
                                isys:epipe
                                error)
                            (lambda (e)
                              (on-socket-error driver socket e))))
              (restart-case
                  (let ((bytes-written (iolib:send-to (socket-internal-socket socket)
                                                      (socket-write-buffer socket)
                                                      :start (socket-write-buffer-offset socket))))
                    (incf (socket-bytes-written socket) bytes-written)
                    (when (>= (incf (socket-write-buffer-offset socket) bytes-written)
                              (length (socket-write-buffer socket)))
                      (setf (socket-write-buffer socket) nil)
                      (when (queue-empty-p (socket-write-queue socket))
                        (if (socket-close-after-drain-p socket)
                            (finish-close socket)
                            (on-socket-output-empty driver socket)))))
                (continue () nil)
                (drop-connection () (close socket :abort t)))))
          (when (queue-empty-p (socket-write-queue socket))
            (return))))))
  
negative.code: (defun finish-close (socket)
    (when-let (evbase (and (slot-boundp socket 'internal-socket)
                           (socket-event-base socket)))
      (pause-writes socket)
      (when-let (server (socket-server socket))
        (remhash socket (server-connections server)))
      (close (socket-internal-socket socket) :abort t)
  