jerome.martin.dev
2019-7-11 07:43:49

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…


jerome.martin.dev
2019-7-11 07:46:21

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


soegaard2
2019-7-11 12:20:31

Thanks!


steveh2009
2019-7-11 15:54:12

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?


steveh2009
2019-7-11 16:00:07

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


jaz
2019-7-11 16:03:55

@steveh2009 read-byte does block until input is available


steveh2009
2019-7-11 16:04:08

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.


steveh2009
2019-7-11 16:05:01

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


jaz
2019-7-11 16:05:22

that’s what it does


steveh2009
2019-7-11 16:10:53

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


jaz
2019-7-11 16:10:55

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)


jaz
2019-7-11 16:11:14

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


jaz
2019-7-11 16:11:44

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


steveh2009
2019-7-11 16:19:10

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.