Really embarrassed I can't figure out what's going on here, but I just 
spent the last two hours banging my head against this going nowhere.


I'm trying to create a simple echo server and client in Racket.


This is the server:


(define (hello_listen port)
    (define listener (tcp-listen port))
    (define (loop)
        (define-values (in out) (tcp-accept listener))
        (thread (lambda ()
                (copy-port in out)
                (close-output-port out)))
        (loop))
    (loop))


And this is the client:


(define (hello_socket port)
    (define-values (in out) (tcp-connect "localhost" port))
    (write "hello socket world\n" out)
    (display (read in)))


The client does not receive any text back, and just hangs on the read. 

When I write a simple client in Python however, the behavior is fine:


>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(('localhost', 9999))
>>> s.send("hi")   
2
>>> s.recv(500)
'hi' 

What am I missing here in the Racket client code?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to