anchor.diff:    (assert (boundp '*mode*))
     (ecase *mode*
       ((:server :client)
  -     (usocket:socket-close *socket*))
  +     (usocket:socket-close *socket*)
  +     (when (eql *mode* :server)
  +       (usocket:socket-close *server-socket*)))
       ((:normal)))
     (makunbound '*socket*)
     (makunbound '*mode*))
   
  -(defun store-to-buffer (object)
  -  (flexi-streams:with-output-to-sequence (stream)
  -    (cl-store:store object stream)))
  -
  -(defun restore-from-buffer (buffer start end)
  -  (flexi-streams:with-input-from-sequence (stream buffer :start start :end end)
  -    (cl-store:restore stream)))
  -
   (defun net-receive (&key timeout)
     (assert (or (eql *mode* :server) (eql *mode* :client)))
  -  #+(not (and sbcl windows))
  -  (usocket:wait-for-input *socket* :timeout timeout :ready-only t)
  -  #+(and sbcl windows) t
  -  (multiple-value-bind (buffer size host port)
  -      (usocket:socket-receive *socket* *buffer* nil)
  -    (values (restore-from-buffer buffer 0 size) host port)))
  +  (cl-store:restore (usocket:socket-stream *socket*)))
   
   (defun net-send (message)
     (assert (or (eql *mode* :server) (eql *mode* :client)))
  -  (let ((buffer (store-to-buffer message)))
  -    (usocket:socket-send *socket* buffer nil
  -                         :host *remote-host* :port *remote-port*)))
  +  (cl-store:store message (usocket:socket-stream *socket*))
  +  (force-output (usocket:socket-stream *socket*)))
   
   (defmacro with-serve-request ((request &key timeout) &body body)
     `(let ((,request (net-receive :timeout ,timeout)))
  
positive.code: (defconstant +max-buffer-size+ 65536)
  
  (defvar *mode*)
  (defvar *local-host*)
  (defvar *local-port*)
  (defvar *remote-host*)
  (defvar *remote-port*)
  (defvar *socket*)
  (defvar *buffer*
    (make-array +max-buffer-size+ :element-type '(unsigned-byte 8)))
  
negative.code: (defun net-init (mode host port)
    (assert (not (boundp '*mode*)))
    (ecase mode
      ((:server)
       (let ((socket (usocket:socket-listen usocket:*wildcard-host* port
                                            :element-type '(unsigned-byte 8))))
         (setf *server-socket* socket
               *local-port* (usocket:get-local-port socket))))
      ((:client)
       (when (eql mode :client)
         (setf *remote-host* host *remote-port* port)))
      ((:normal)))
    (setf *mode* mode))
  
  (defun net-connect (&optional (abort-handler #'default-abort-handler))
    (ecase *mode*
      ((:server)
       (usocket:wait-for-input *server-socket* :timeout nil :ready-only t)
       (setf *socket* (usocket:socket-accept *server-socket*))
       (let ((request (net-receive)))
         (unless (equal (assoc :request request) '(:request :init))
           (funcall abort-handler))
         (net-send '((:response :init)))))
      ((:client)
       (setf *socket* (usocket:socket-connect *remote-host* *remote-port*
                                              :element-type '(unsigned-byte 8)))
       (net-send `((:request :init)))
       (unless (equal (net-receive :timeout 10) '((:response :init)))
         (funcall abort-handler)))
      ((:normal))))
  