
I recall that someone tried to have a Racket meeting in Microsoft offices in London last year, but I don’t know if it actually happened. I’ll check the archives…

Found it! That was actually you, Stephen :stuck_out_tongue: https://www.mail-archive.com/racket-users@googlegroups.com/msg40429.html

Thanks!

I am using read-byte on a socket input port. Is there a way to block (forever, unless, of course, the actual connection is closed from the server side) on that read if a byte is not available?

Set file-stream-buffer-mode to ’block ?

@steveh2009 read-byte
does block until input is available

I did a (file-stream-buffer-mode inp ’block) after getting back the tcp-connect in and out ports. Seems the read-byte is not blocking forever.

Is there a way to hang on input socket if nothing is there?

that’s what it does

This is totally my bad. Event loop is on a different thread hanging, bottom of main thread test code has a call to disconnect.

try this: #lang racket/base
(require racket/tcp)
(define listener (tcp-listen 6666))
(displayln "waiting for client")
(define-values (in out) (tcp-accept listener))
(displayln "got client; waiting on byte")
(displayln (format "got byte ~a" (read-byte in)))
(close-input-port in)
(close-output-port out)

and, in a terminal, telnet localhost 6666
to act as the client

the read-byte
will block until you provide it with data

Good news is this TWS API I’ve received help from here is humming along now. Now comes just extensive test cases to ensure it’s basically solid and then I’ll setup a github account (yes, I’m the last one) and then maybe some here could glance at it to remove beginner-isms. Then, doc it and package it. Super positive experience as my first Racket project. FUN coding experience, imho.