From ca6a66c5bbd26fb490b563189bd292a7c7f5f8a0 Mon Sep 17 00:00:00 2001
From: jsancho <devnull@localhost>
Date: Fri, 6 Nov 2009 19:10:05 +0000
Subject: [PATCH]

---
 gacela.lisp | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gacela.lisp b/gacela.lisp
index de3a3f8..5d6eae0 100644
--- a/gacela.lisp
+++ b/gacela.lisp
@@ -204,13 +204,19 @@
     (maphash (lambda (key res) (free-resource key)) resources-table)))
 
 
-;;; Connection with the GUI
-(let (socket)
-  (defun connect-to-gui ()
-    (setq socket (si::socket 1984 :host "localhost")))
+;;; Gacela Server for development mode
+(let (socket clients)
+  (defun server-running? ()
+    (if socket t nil))
 
-  (defun eval-from-gui ()
-    (cond ((and socket (listen socket)) (eval (read socket))))))
+  (defun start-server (port)
+    (setq socket (si::socket port :server #'eval-from-client)))
+
+  (defun check-server-connections ()
+    (when (si::listen socket) (push (si:accept socket) clients)))
+
+  (defun eval-from-clients ()
+    (dolist (cli clients) (when (si::listen cli) (eval (read cli))))))
 
 
 ;;; GaCeLa Functions
-- 
2.39.5