The return code from sendto() and recvfrom() is the number of bytes sent or -1 for an error so the check for an error here should be ret<0, not ret!=0 https://github.com/emscripten-core/emscripten/blob/8373cfa4d4a83f7840a46a4de81cc58ca8a9ea5e/tools/websocket_to_posix_proxy/src/websocket_to_posix_proxy.c#L1217 https://github.com/emscripten-core/emscripten/blob/8373cfa4d4a83f7840a46a4de81cc58ca8a9ea5e/tools/websocket_to_posix_proxy/src/websocket_to_posix_proxy.c#L1259