Question

I'm building a C++ application that produces data that I want to pipe to a web browser. If I send all of the data to the server, and then out to clients, there will be too much traffic. Is there a way I can use my server to establish a direct socket connection between my C++ application and a remote browser?

I'm writing my server using node.js for what it's worth

Was it helpful?

Solution

Yes: you can embed a web server inside your C++ application. If you can poll for the data using simple HTTP GET, you can use the simple C web server library "mongoose" for example. Or you may need to use WebSockets which probably requires a fancier library in C or C++. Then your Node.js server can simply give the URL of your C++ server to the clients, who will connect to the C++ server directly.

All that being said, it's likely that Node.js can support the load, so if you haven't actually run into scaling problems, you might want to just skip this whole project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top