From: jsancho Date: Thu, 7 Jul 2011 19:19:44 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=39b00720d1fbe4762abb8bd5aab37572a31028f2;p=gacela.git --- diff --git a/src/gacela_server.scm b/src/gacela_server.scm index 548488e..a95ec9d 100644 --- a/src/gacela_server.scm +++ b/src/gacela_server.scm @@ -17,6 +17,7 @@ (define start-server #f) (define check-connections #f) +(define eval-from-clients #f) (define stop-server #f) (let ((server-socket #f) (clients '())) @@ -34,6 +35,21 @@ (lambda () (set! clients (cons (accept server-socket) clients))) (lambda (key . args) #f)))) + (set! eval-from-clients + (lambda () + (for-each + (lambda (cli) + (let ((sock (car cli))) + (cond ((char-ready? sock) + (catch #t + (lambda () (eval (read sock))) + (lambda (key . args) #f)))))) + clients))) + (set! stop-server (lambda () - (cond (server-socket (close server-socket) (set! server-socket #f))) \ No newline at end of file + (cond (server-socket + (close server-socket) + (set! server-socket #f))) + (for-each (lambda (cli) (close (car cli))) clients) + (set! clients '()))))