2. make sure the WebSocket is ready when calling a method:
```cc
int main(int argc, char *argv[]) {
#ifdef __EMSCRIPTEN__
if (!bridgeSocket) {
bridgeSocket = emscripten_init_websocket_to_posix_socket_bridge("ws://localhost:8080");
// Synchronously wait until connection has been established.
uint16_t readyState = 0;
do {
emscripten_websocket_get_ready_state(bridgeSocket, &readyState);
emscripten_thread_sleep(100);
} while (readyState == 0);
}
#endif
....
Link with flags -lwebsocket.js -sPROXY_POSIX_SOCKETS -sUSE_PTHREADS -sPROXY_TO_PTHREADreference
In case it helps improving the WASM port, I was able to perform a simple socket connection following these steps:
blink.c
; referencestatic EMSCRIPTEN_WEBSOCKET_T bridgeSocket = 0;
endif
-lwebsocket.js -sPROXY_POSIX_SOCKETS -sUSE_PTHREADS -sPROXY_TO_PTHREAD
reference