[plt-scheme] run-server

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Oct 7 12:06:02 EDT 2002

At 02 Oct 2002 18:15:46 +0100, Paulo J. Matos wrote:
> (define echo
>   (lambda (inputport outputport)
>     (printf "Iteration~n")
>     (write (read-line) outputport)

I think the problem is here. The result from `read-line' does not
include the newline, so the line sent back to the server is not complete.

>     (printf "Waiting for char...~n")
>     (wait-char inputport)
>     (display (read-line inputport))
>     (echo inputport outputport)))
> 
> (define wait-char
>   (lambda (port)
>     (let recur ()
>       (if (not (char-ready? port))
>           (recur)))))
> [...]
> Also, my
> wait-char, is not very good. How can I make it sleep until it
> receives something?

Indeed --- simply delete the call to `wait-char'. `read-line' will block
until it consumes a line.

In the rare case that you need to block explicitly, use
`object-wait-multiple'.

Matthew



Posted on the users mailing list.