[plt-scheme] Reading on TCP ports and #<eof>
Hi,
I try to read expressions from a TCP port in a loop like this one:
(define (connection-start-client-listen connection)
(thread
(lambda ()
(let loop ((in (read (connection-in-port connection))))
(info "~a ~s" (connection-name connection) in)
(if (is-reply? in)
(handle-reply connection (car in))
(info "illegal reply: '~s'" in))
(loop (read (connection-in-port connection)))))))
When (connection-in-port connection) yields a port obtained from a
make-pipe, this works well. However, when the port is a TCP-port, it
seems that the call to read doesn't block, but instead returns #<eof>
each time it is called. The loop becomes rather busy and my info
procedure continuously outputs "illegal reply: #<eof" when the server
the client has connected to doesn't send anything.
How do I block the thread until some value different from #<eof> is
read? Why is a tcp port behaving differently from one produced by
make-pipe?
Regards,
Erich