   "docstring"
   (make-local-variable 'emdocs-ip-addr)
   (setq emdocs-ip-addr (read-from-minibuffer "ip: "))
-  (emdocs-attach-sockets-to-buffer (current-buffer) emdocs-ip-addr))
+  ;; check for private ips
+  (if (or (string-match "^192\\.168\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
+          (string-match "^10\\.[0-9]+\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
+          (string-match "^172\\.1[6789]\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
+          (string-match "^172\\.2[0-9]\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
+          (string-match "^172\\.3[01]\\.[0-9]+\\.[0-9]+$" emdocs-ip-addr)
+          (string-equal "" emdocs-ip-addr)
+          (string-equal "localhost" emdocs-ip-addr))
+      (emdocs-attach-sockets-to-buffer (current-buffer) emdocs-ip-addr)
+    (message
+"Invalid ip address. Keep in mind emdocs only works for private ip addresses.")
+    (setq emdocs-mode nil)))
 
 (defun emdocs-disconnect ()
   "docstring"
-  (when (and emdocs-server
-             (not (eq emdocs-server 'no-conn)))
-    (delete-process emdocs-server))
-  (makunbound 'emdocs-server)
   (loop for client in emdocs-client-list
         do (when (and client
                       (not (eq client 'no-conn)))
              (delete-process client)))
   (makunbound 'emdocs-client-list))
+
+(defun emdocs-kill-server ()
+  "docstring"
+  (interactive)
+  (if (and *emdocs-server*
+           (not (eq (process-status *emdocs-server*) 'closed)))
+      (delete-process *emdocs-server*))
+  (setq *emdocs-server* nil))
 
 ;;; define mode
 

  "docstring"
  (let ((my-ip (emdocs-get-internal-ip-address)))
    (if my-ip
        (progn
          (make-local-variable 'emdocs-server)
          (setq emdocs-server nil)
          (setq emdocs-server           ; the setq is required, not sure why
                (condition-case emdocs-server
                    (emdocs-setup-server buffer my-ip)
                  (file-error 'no-conn)))
          (if (eq emdocs-server 'no-conn)
              (progn
                (message "Server could not connect: exiting.")
                (setq emdocs-mode nil)
                (emdocs-disconnect))
            (make-local-variable 'emdocs-client-list)

                    (condition-case emdocs-client-list
                        (cons (emdocs-connect-client buffer ip) nil)
                      (file-error 'no-conn))))
            (if (eq emdocs-client-list 'no-conn)
                (progn (message "Client could not connect: exiting.")
                       (setq emdocs-mode nil)
                       (emdocs-disconnect))
              (insert "DO AFTER-CHANGE FUNCTIONS"))))
      (message "Not connected to internet: exiting.")
      (setq emdocs-mode nil)
      (emdocs-disconnect))))
