Communicating between a locally-running rust program and WASM

A program I've built can input/output serde-serialized structures into a loopback TCP connection. Consider this program A. The idea is that program A, a locally-running background application, can communicate with program B, a standalone rust program compiled for WASM. All I want is for communication between A and B to occur. I could use websockets, but those are an unnecessary amount of abstraction for a loopback connection. I have searched around, and it appears that a TcpStream does not readily exist for WASM, even though websockets are a higher-level abstraction than TcpStreams. What is the best way to communicate between a rust program and a WASM program?

WASM can only do things that Javascript can do. In terms of networking this is limited to HTTP requests and things built on top of that like SSE and Websockets. There is no raw TCP transport from WASM. You may be interested in software like Websockify though.

Where do you want to run the WASM? In the browser you are limited to WebSockets at best.