                     :filter (lambda (sock msg)
                               (emdocs-client-filter buffer sock msg))
                     :server nil
-                    :noquery t))))
-    (add-to-list '*emdocs-outgoing-clients*
-                 (make-instance 'emdocs-outgoing-client
-                                :process process
-                                :buffer buffer
-                                :ip ip))
-    process))
+                    :noquery t)))
+       (add-to-list '*emdocs-outgoing-clients*
+                    (make-instance 'emdocs-client
+                                   :process process
+                                   :attached-buffer (if (bufferp buffer)
+                                                        (buffer-name buffer)
+                                                      buffer)
+                                   :ip ip)))
+    ;; )
+ )
 
 (defun emdocs-broadcast-message (msg)
   (loop for client in *emdocs-server-clients*

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

(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-i
         (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)))

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

                     (string-match "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" msg)
                     (match-string-no-properties 0 msg))))
           (unless (find ip *emdocs-outgoing-clients*
                         :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*)))
        ))

(defun emdocs-server-filter (sock msg)
  "docstring"
