From: jsancho Date: Thu, 7 Jul 2011 18:25:07 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=71acfe50145894e950d1d9deb656fb36132b5de3;p=gacela.git --- diff --git a/src/gacela_server.scm b/src/gacela_server.scm index e7a69c6..548488e 100644 --- a/src/gacela_server.scm +++ b/src/gacela_server.scm @@ -16,12 +16,24 @@ (define start-server #f) +(define check-connections #f) +(define stop-server #f) (let ((server-socket #f) (clients '())) (set! start-server (lambda (port) (set! server-socket (socket PF_INET SOCK_STREAM 0)) + (fcntl server-socket F_SETFL (logior O_NONBLOCK (fcntl server-socket F_GETFL))) (setsockopt server-socket SOL_SOCKET SO_REUSEADDR 1) (bind server-socket AF_INET INADDR_ANY port) (listen server-socket 5))) -) + + (set! check-connections + (lambda () + (catch #t + (lambda () (set! clients (cons (accept server-socket) clients))) + (lambda (key . args) #f)))) + + (set! stop-server + (lambda () + (cond (server-socket (close server-socket) (set! server-socket #f))) \ No newline at end of file