We’ve had great success deploying WebSocket in lieu of TCP for server-to-server communication. You harness the routing that a web framework like Mojo does for you--so no futzing with firewalls and the like--but you still get the real-time communication that a raw TCP socket would give you. There’s a CLI utility called “websocat” that basically functions as “netcat for WebSocket”, if that’s of use to you.
An alternative technology, if you only need a server-to-client stream, is Server-Sent Events (SSE). It’s basically an open-ended HTTP response, with the client parsing each chunk of that response as it arrives. Most browsers support it via the EventStream object, and I suspect it’d be pretty straightforward to rig up a Mojo SSE client, too. It’s a bit simpler, too, since it follows HTTP semantics. Not as robust, though, as it lacks the close status mechanism that WebSocket provides. (The server basically has to wait until it sees EPIPE/SIGPIPE to know that the client has stopped listening.)
-FG