                      (string-match "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" msg)
                      (match-string-no-properties 0 msg))))
            (unless (find ip *emdocs-outgoing-clients*
-                         :test (lambda (test-ip client)
-                                 (string-equal test-ip
-                                               (emdocs-get-ip client))))
+                         :test #'emdocs-is-ip-from-client)
              (process-send-string sock "give me buffer and ip\n"))))
-        ((string-match "^connection broken by remote peer\n$" msg)
-         (setq *emdocs-server-clients*
-               (remove-if
-                (lambda (item)
-                  (equal (car item) sock))
-                *emdocs-server-clients*)))))
+        ;; ((string-match "^connection broken by remote peer\n$" msg)
+        ;;  (setq *emdocs-server-clients*
+        ;;        (remove-if
+        ;;         (lambda (item)
+        ;;           (equal (car item) sock))
+        ;;         *emdocs-server-clients*)))
+        ))
 
 (defun emdocs-server-filter (sock msg)
   "docstring"


;;; classes

(defclass emdocs-incoming-client ()
  ((process
    :initarg process
    :accessor emdocs-get-process)
   (buffer
    :initarg buffer
    :accessor emdocs-get-buffer)))

(defclass emdocs-outgoing-client (emdocs-incoming-client)
  ((ip
    :initarg ip
    :accessor emdocs-get-ip)))

;;; functions

"Invalid ip address. Keep in mind emdocs only works for private ip addresses.")
    (setq emdocs-mode nil)))

(defun emdocs-test-if-client-attached-to-buffer (client)
  (string-equal
   (emdocs-get-attached-buffer client)
   (buffer-name)))

(defun emdocs-disconnect ()
  "docstring"
  ;; (loop for client in emdocs-initial-client
  ;;       do (when (and client
  ;;                     (not (eq client 'no-conn)))
  ;;            (delete-process client)))
  ;; (setq emdocs-initial-client nil)
  ;; (loop for client in *emdocs-server-clients*
  ;;       do (when (string-equal (car client) (buffer-name (current-buffer)))
  ;;            (delete-process (cdr client))))
  ;; (setq *emdocs-server-clients*
  ;;       (remove-if
  ;;        (lambda (item)
  ;;          (string-equal (car item) (buffer-name (current-buffer))))
  ;;        *emdocs-server-clients*))
  ;; (setq-local after-change-functions
  ;;             (remove #'emdocs-after-change-lambda after-change-functions))
  (loop for client in *emdocs-outgoing-clients*
        do (when (emdocs-test-if-client-attached-to-buffer client)
             (delete-process (emdocs-get-process client))))
  (setq *emdocs-outgoing-clients*
        (remove-if #'emdocs-test-if-client-attached-to-buffer
                   *emdocs-outgoing-clients*))
  (loop for client in *emdocs-incoming-clients*
        do (when (emdocs-test-if-client-attached-to-buffer client)
             (delete-process (emdocs-get-process client))))
  (setq *emdocs-incoming-clients*
        (remove-if #'emdocs-test-if-client-attached-to-buffer
                   *emdocs-incoming-clients*)))

;;; interactives
(defun emdocs-kill-server ()
