Hi, I'm trying to write an application server in Scheme with Bigloo implementation. The code:
(module server
(library fthread)
(main main))
(define *port-num* 8080)
(define (main argv)
(let* ((socket0 (make-server-socket *port-num*))
(ts (thread-start! (make-thread (lambda () (start-server socket0))))))
(scheduler-start!)
(fprint (current-error-port) "Shutting down...")))
(define (start-server socket0)
(lambda ()
(print "Starting server...")
(let loop ()
(let ((s (socket-accept socket0)))
(print "New connection: " s)
(thread-start! (make-thread (lambda () (handle-request s))))
(thread-yield!)
(loop)))))
(define (handle-request s)
(print "new request")
(socket-shutdown s #f))
It compiles OK, but program terminates immediately after starting:
$ bigloo -o server server.scm
$ ./server
Shutting down...
Where I'm wrong?
Thanks a lot.