It sounds like you are trying to use some code running inside a page/worker on Chrome as a server, but as far as I know both the browser and curl are intended as clients.
I'd be quite surprised if a browser let you start a TCP listener, so that rendezvous HTTP server might be necessary.
Alternatively, what about creating a helper program that starts up the websockets server and prints a URL you can open in your browser. Then when Chrome connects you do the normal websockets thing to get a REPL.
I think I did the thing you want to do in this game I wrote. The code is here and a playable version of the game is here.
Originally, I had the game run on a server, communicating with the player’s browser via a websocket. I wanted to host the game on Github Pages, so I used wasm to put the game in the player’s browser. It works pretty well, though this means the AI is weaker on phones than on computers.
Instead of a websocket, the browser now uses a webworker so that thinking won’t make the user interface less responsive. Only the webworker can call into the compiled wasm.