anchor.diff:      (write-socket-data bev data)
       (set-socket-timeouts bev read-timeout write-timeout)
   
  -    (format t "socket: ~s~%" (le:bufferevent-getfd bev))
       (unless bev-exists-p
         ;; connect the socket
         (if (ip-address-p host)
  
positive.code: (defconstant +sockaddr-size+ (cffi:foreign-type-size (le::cffi-type le::sockaddr-in))
    "Really no sense in computing this OVER AND OVER.")
  
  (define-condition connection-error (error)
    ((bufferevent :initarg :bufferevent :reader connection-error-bufferevent :initform nil)
     (connection :initarg :connection :reader connection-error-connection :initform nil))
    (:report (lambda (c s) (format s "Connection error: ~a~%" (connection-error-connection c))))
    (:documentation "Describes a connection error. Meant to be extended."))
  
  (define-condition connection-timeout (connection-error) ()
    (:report (lambda (c s) (format s "Connection timeout: ~a~%" (connection-error-bufferevent c))))
    (:documentation "Passed to a failure callback when a connection times out."))
  
  (define-condition connection-refused (connection-error) ()
    (:report (lambda (c s) (format s "Connection refused: ~a~%" (connection-error-bufferevent c))))
    (:documentation "Passed to a failure callback when a connection is refused."))
  
  (define-condition connection-dns-error (connection-error)
    ((msg :initarg :msg :reader connection-dns-error-msg :initform nil))
    (:report (lambda (c s) (format s "Connection DNS error: ~a~%" (connection-error-bufferevent c))))
    (:documentation "Passed to a failure callback when a DNS error occurs on a connection."))
  
  (defun close-socket (bev)
    "Free a socket and clear out all associated data."
  
negative.code: (cffi:defcallback tcp-event-cb :void ((bev :pointer) (events :short) (event-base :pointer))
    "Called whenever anything happens on a TCP socket. Ties into the anonymous
     callback system to track failures/disconnects."
    (declare (ignore event-base))
    (cond
      ((< 0 (logand events le:+bev-event-connected+))
       nil)
      ((< 0 (logand events (logior le:+bev-event-error+
                                   le:+bev-event-eof+
                                   le:+bev-event-timeout+)))
       (unwind-protect
         (multiple-value-bind (errcode errstr) (get-last-tcp-err)
           (let ((err nil)
                 (connection (le:bufferevent-getfd bev))
                 (dns-err (le:bufferevent-socket-get-dns-error bev))
                 (fail-cb (getf (get-callbacks bev) :fail-cb)))
             (cond
               ;; DNS error
               ((and (< 0 (logand events le:+bev-event-error+))
                     (not (zerop dns-err)))
                (setf err (make-instance 'connection-dns-error
                                         :connection connection
                                         :msg (le:evutil-gai-strerror dns-err))))
  
               ;; socket timeout
               ((< 0 (logand events le:+bev-event-timeout+))
                (setf err (make-instance 'connection-timeout :connection connection :code errcode :msg errstr)))
  
               ;; peer closed connection.
               ((< 0 (logand events le:+bev-event-eof+))
                (setf err (make-instance 'connection-eof :connection connection :code errcode :msg errstr)))
  
               ;; since we don't know what the error was, just spawn a general
               ;; error.
               (t
                (setf err (make-instance 'connection-error :connection connection :code errcode :msg errstr))))
             (funcall fail-cb err)))
         (close-socket bev)))))
  
  (cffi:defcallback tcp-accept-cb :void ((listener :pointer) (fd :int) (addr :pointer) (socklen :int) (ctx :pointer))
    "Called when a connection is accepted. Creates a bufferevent for the socket
  