anchor.diff:           (local-port (ub16ref/be packet (+ start +tcp4-header-destination-port+)))
            (flags (ldb (byte 12 0)
                        (ub16ref/be packet (+ start +tcp4-header-flags-and-data-offset+))))
  -         (connection (get-tcp-connection remote-ip remote-port local-ip local-port)))
  +         (connection (get-tcp-connection remote-ip remote-port local-ip local-port))
  +         (listener (get-tcp-listener local-ip local-port)))
       (cond
         (connection
          (tcp4-receive connection packet start end))
  +      ((and listener (eql flags +tcp4-flag-syn+))
  +       (let ((connection (make-instance 'tcp-connection
  +                                        :%state :listen
  +                                        :local-port local-port
  +                                        :local-ip local-ip
  +                                        :remote-port remote-port
  +                                        :remote-ip remote-ip
  +                                        :s-next 0
  +                                        :r-next (ub32ref/be packet (+ start +tcp4-header-sequence-number+))
  +                                        :window-size 8192)))
  +         (mezzano.supervisor:with-mutex ((tcp-listener-lock listener))
  +           (push connection (tcp-listener-connection listener)))
  +         (mezzano.supervisor:with-mutex (*tcp-connection-lock*)
  +           (push connection *tcp-connections*))))
         ((eql flags +tcp4-flag-syn+)
          (tcp4-establish-connection local-ip local-port remote-ip remote-port packet start end))
         (t (format t "Ignoring packet from ~X ~X ~S~%" remote-ip flags
                    (subseq packet start end))))))
  +
  +(defun tcp4-accept-connection (connection)
  +  (let* ((seq (random #x100000000))
  +         (ack (logand #xFFFFFFFF (1+ (tcp-connection-r-next connection)))))
  +    (setf (tcp-connection-state connection) :syn-received
  +          (tcp-connection-s-next connection) (logand #xFFFFFFFF (1+ seq))
  +          (tcp-connection-r-next connection) ack)
  +    (tcp4-send-packet connection seq ack nil :ack-p t :syn-p t)
  +    (make-instance 'tcp-stream :connection connection)))
  +
  +(defun tcp4-decline-connection (connection)
  +  (close connection)
  +  (detach-tcp-connection connection))
   
   (defun tcp4-establish-connection (local-ip local-port remote-ip remote-port packet start end)
     (let* ((seq (ub32ref/be packet (+ start +tcp4-header-sequence-number+)))
  
positive.code: 
  (defvar *tcp-connections* nil)
  (defvar *tcp-connection-lock* (mezzano.supervisor:make-mutex "TCP connection list"))
  (defvar *allocated-tcp-ports* nil)
  
  (defvar *server-alist* '())
  
  (defclass tcp-connection ()
    ((%state :accessor tcp-connection-%state :initarg :%state)
  
negative.code:            (header-length (* (ldb (byte 4 12) flags-and-data-offset) 4))
             (data-length (- end (+ start header-length))))
        (case (tcp-connection-state connection)
          (:listen
           ;; Remote has start new connection.
           ;; Not much to do here, just waiting for the application to accept or decline new connection.
           )
          (:syn-sent
           (cond ((and (logtest flags +tcp4-flag-ack+)
                       (logtest flags +tcp4-flag-syn+)
  