+;; -*- lexical-binding: t; -*-
+
 (eval-when-compile
   (require 'cl))
 


(defun emdocs-setup-server (buffer my-ip)
  "docstring"
  (make-local-variable 'emdocs-server)
  (setq emdocs-server
        (make-network-process
         :name (concat "*emdocs-server:" (buffer-name buffer) "*")
         ;; TODO: remove the log buffer
         :buffer (concat "*emdocs-server-log:" (buffer-name buffer) "*")
         :family 'ipv4
         :host ip
         :service +emdocs-http-port+
         :sentinel (lambda (sock msg)
                     (emdocs-server-sentinel buffer sock msg))
         :filter (lambda (sock msg)
                   (emdocs-server-filter buffer sock msg))
         :server t
         :noquery t)))

(defun emdocs-client-sentinel (buffer sock msg)
  "docstring")


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

;;; define mode

