[plt-scheme] Why does this TCP client block?

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Wed Jul 23 22:24:09 EDT 2008

`flush-output' ?

Chongkai

Gregory Woodhouse wrote:
> I'm not having a problem with the "More" tutorial per se, but 
> in trying to adapt it, I've run into a problem. I'm sure this is user 
> error on my part, but I've modified the early examples to read 
> s-expressions and write them back. Unfortunately, my test driver 
> blocks when trying to read a response back from the server. Testing 
> with telnet works fine.
>
> Here is the test driver
>
> ;;A simple test driver
> (define (test-it port-no)
>   (begin
>     (printf "Starting server on port ~a~n" port-no)
>     (let ([stop (serve port-no test-handler)])
>     (printf "Connecting to server on port ~a~n" port-no)
>     (let-values ([(in out) (tcp-connect "localhost" port-no)])
>     (define msg '(a b c))
>     (printf "Sending message ~a~n" msg)
>     (write msg out)
>     (printf "Reading response...~n")
>     (let ([resp (read in)])
>           (printf "Response is ~a~n" msg))
>     (printf "Stopping server."))
>     (stop))))
>
>
>
> "Oh would that my mind could let fall its dead ideas, as the tree does 
> its withered leaves."
> --André Gide
>
> http://www.gwoodhouse.com
> http://GregWoodhouse.ImageKind.com
>
>
>
>
> ------------------------------------------------------------------------
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   



Posted on the users mailing list.