                             (cons emdocs-after-change-lambda
                                   after-change-functions))
                 (add-hook 'kill-buffer-hook #'emdocs-disconnect)
-                (add-hook 'kill-emacs-hook #'emdocs-kill-server)))))
+                (add-hook 'kill-emacs-hook #'emdocs-kill-server)
+                (emdocs-broadcast-buffer-at-intervals buffer)))))
       (message "Not connected to internet: exiting.")
       (setq emdocs-mode nil)
       (emdocs-disconnect))))
 
-(defun emdocs-connect ()
+(defun emdocs-connect (buffer)
   "docstring"
   (setq emdocs-ip-addr (read-from-minibuffer "ip: "))
   ;; check for private ips

            (define-key map (kbd "C-c C-c") 'emdocs-mode)
            map)
  (if emdocs-mode
      (emdocs-connect)
    (emdocs-disconnect)))

(provide 'emdocs-mode)

             (unless (find ip *emdocs-outgoing-clients*
                           :test #'emdocs-is-ip-from-client)
               (emdocs-connect-client buffer ip))
             (emdocs-broadcast-message msg))))))

(defun emdocs-setup-server (my-ip)
  "docstring"
