I have a go program that creates a TCP server using the below line of code:
server, err := net.Listen("tcp", "localhost:8080")
I have converted the go program to wasm module with wasi as target using below command
tinygo build -o wasm_net.wasm -target wasi ./server.go
I have then tried to run the wasm module using the following ways with wasmer
and wasmtime
wasmer run --enable-all wasm_net.wasm -- localhost 8080
or
wasmtime run --tcplisten localhost:8080 --wasm-features=all wasm_net.wasm localhost 8080
or
wasmtime run --wasm-features=all wasm_net.wasm localhost 8080
All of them gave the following error/out
operation not implemented
Referencing to https://github.com/bytecodealliance/wasmtime/issues/5867#issuecomment-1442218885 from bjorn3.
How was the binary compiled? From what I can gather go doesn't yet support wasi. Are you using tinygo? I think tinygo doesn't support network functionality yet and throws that exact "operation not implemented" error: https://github.com/tinygo-org/tinygo/blob/0d56dee00f49bd50eb373c02c30062a75ec28f10/src/net/dial.go#L20
No network functionality for Go wasm modules yet.