[plt-scheme] How does run-server work?

From: Erich Rast (erich at snafu.de)
Date: Thu Jul 19 12:24:53 EDT 2007

Hello,

I can't figure out how run-server in the "thread.ss" library works.  
Here is an example:

(require (lib "thread.ss"))

(define s (thread (lambda () (run-server 8192
                                          (lambda (in out)
                                            (let loop ((input (read  
in)))
                                              (display input)(newline)
                                              (loop (read in))))
                                          #f))))

(define (test)
   (let-values (((in out) (tcp-connect "127.0.0.1" 8192)))
     (write "Hello world!  
Heeeeeeeeeeeeelllllllllllllooooooooooooooooo!!  
HEEEEEELLLLLLLOOOOOOOOOOOO!!!! Hello? Anybody there?\n" out)))

Running (test), nothing is displayed, even though everything looks  
fine:  (thread-dead? s) ==> #f, (thread-running? s) ==> #t
Using "localhost" instead of "127.0.0.1" makes no difference. I've  
looked at the source code of run-server but it's a bit over my head.

What's wrong?

Regards,

Erich


Posted on the users mailing list.