I have some existing server code written in C++, Node.js and Python that I would like to port to WASM. This code makes heavy use of UDP/TCP sockets. Ideally with little to no modification of the code.
I know this type of question has been asked a number of times, and the answer is to convert them to websockets and use a bridge. However, this adds another moving part that I'd like to avoid if at all possible.
The code runs as a service on desktop, not in the browser. I know that there's a WASI proposal for sockets that is implemented by WasmEdge.
I'm quite new to WASM and still a little hazy on how it all fits together. Any advice on how to solve this would be greatly appreciated.
Thanks in advance!
I've tried two approaches and am unsure how best to proceed:
#1 Use WasmEdge - but I don't quite understand how to compile to WASM in a way that will take advantage of WasmEdge's socket support. For example, using emscripten will always convert the sockets to websocket.
#2 Create a Node.js wrapper that handles the sockets directly and passes the contents of the buffers back and forth with the embedded WASM module. This isn't ideal as I'd have to modify the source code or at the least create a shim of some kind to replace networking.