anchor.diff:     (bytes-written :initform 0 :accessor socket-bytes-written)
      (external-format-in :initarg :external-format-in :reader socket-external-format-in)
      (external-format-out :initarg :external-format-out :reader socket-external-format-out)
  -   (binary-p :initarg :binaryp :accessor socket-binary-p)))
  +   (binary-p :initarg :binaryp :accessor socket-binary-p)
  +   (close-after-drain-p :initform nil :accessor socket-close-after-drain-p)))
   (defun make-socket (driver &key
                       (buffer-size *max-buffer-size*)
                       (external-format-in *default-external-format*)
  
positive.code:                          (socket-event-base socket)))
      (iolib:remove-fd-handlers evbase
                                (iolib:socket-os-fd (socket-internal-socket socket))
                                :read t :write t :error t)
      (close (socket-internal-socket socket) :abort abort)
      (when-let (server (socket-server socket))
        (remhash socket (server-connections server)))
      (unregister-socket socket)
      (on-socket-close (socket-driver socket) socket)))
  
  (defun socket-connect (driver host &key
                         (port 0)
  
negative.code:                     SOCKET-EXTERNAL-FORMAT-OUT will only be used when converting input strings for
                      output -- binary input data (as through WRITE-SEQUENCE) will not be
                      converted. SOCKET-EXTERNAL-FORMAT-IN is not used at all in binary mode.
                      This value can be changed after a socket has already been created.")
     (close-after-drain-p ((socket a))
      :accessorp t
      :documentation "When true, the internal socket will be closed once the socket's output buffer is
                      drained."))
    (:prefix socket-))
  
  ;;; Implementation
  