On 02/12/2016 07:33 PM, Ty Coghlan wrote:
Both of you were correct, I had to flush my output and newline
terminate it. The final result looks like:

(define (broadcast source destination type message port)
   (let ([h (hash 'source source 'dest destination
                  'type type 'message message)])
     (fprintf port "~a\n" (jsexpr->string h))
     (flush-output port)))

I do have a couple of followup questions. Will flushing the output
have issues when multiple bridges are active at once? The actual data
packets are small enough that I doubt it'd overflow a buffer, if that
helps.

Your program is single-threaded, so I don't know what kinds of issues could come up. And ever if you run multiple copies of your program simultaneously, the communication is connection-based, so they shouldn't interfere.

When I compile this program, I notice that it takes up 5MB of space.
Is that because it's also compiling the c library that unix-socket
wraps? Or is the JSON library that large?

By compile do you mean `raco exe`? Most of that space is probably the Racket VM (the racket binary on my machine is about 3.6 MB). The rest is the bytecode for racket language, json library, etc. You could trim that a bit by using `#lang racket/base` instead of `#lang racket`.

Ryan

--
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