Building existing C++ application using sockets using em++

468 views
Skip to first unread message

Taimoor Mirza

unread,
Jul 1, 2022, 2:21:41 PM7/1/22
to emscripten-discuss
Hi,

I have a C++ based application that acts a server and listens for connection on a port passed to it in args. You can say its more like a GDB Server that eventually will run in my browser and listen on a port and my remote GDB client (on another machine) can then connect to it. I am planning to build this application with em++ and use it from my javascript code.
I was able to build my app after various issues but it did not work. Looking at emscripten testsuite, I found some basic socket servers but it seems they rely on running something like WebSockify on the server side to enable the TCP server stack to receive incoming WebSocket connections. But this requires running an external application...Can't I do all this from within my javascript code that will be running in my browser. My plan was:

I'll build wasm for my server application, My JS code will run this wasm and will also run websockify and then it will listen for connections as it does when I run it natively on my host.

Thanks,
Taimoor

Sam Clegg

unread,
Jul 2, 2022, 9:30:20 AM7/2/22
to emscripte...@googlegroups.com
In general it is not possible to "listen" in the way you describe using any web platform API.  We only have the WebSockets.

All the current ways of doing networking in emscripten are documented at https://emscripten.org/docs/porting/networking.html  IIUC the only method that has any kind of "listen" ability is "Full POSIX Sockets over WebSocket Proxy Server" which does require a server and there are no alternatives that I'm aware of.

cheers,
sam

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/4c3fba21-29f7-4f18-9e78-2595ce1fce83n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages