> C++ backend communication

In my nearest future I will have to make a system with C++ backend and web frontend (requirements). At the moment, I don't know much more about it. I think that Frontend will be triggering data delivery, not backend - so no need for Comet-like things.

Because of possibly little experience in this field, I'd really appreciate your comments about design decisions I made.

First of all, I don't like the option of generating HTML from C++. So, C++ backend will have to communicate with Javascript frontend. Simplest option I see here is Ajax. I think it should be ok, so far.

Commucating through Ajax with C++ backend means that backend should be capable of handling HTTP. It'd be nice to separate backend which provides actual data from HTTP handling functionality.

Here I see the place for Node.js. I got an overview of it and this's the place where all my doubts lie.

To have a HTTP handling server on Node.js, which will have the 'data backend' as a Node.js module? I think, it should be ok - but I'm not sure that I really need all this asynchronization, so there may be some simpler options I'm not aware of? How would you make such a system?

Thanks in advance.


"All this asynchronization" is not something that Node.js works very hard to provide as an extra. It is a different view of Web serving that is easy as breathing once you understand how Node.js works.

For example, my colleagues needed a way to wrap a C++ program as a web service, but the program had a significant start-up cost, so they wanted to run just one instance of the program, running in a loop, serving all the web requests. The whole thing in Node.js took less than two screenfuls.

Wrapping a single program that is called for each request can be done in less than ten lines of Node.js. Don't think of asynchronicity as a chore - if you embrace it, Node.js is awesome.

That said, you could go the CGI route, and do it in a bit more standard way, and the end result would be pretty much the same. This may or may not come in handy.


Did you consider CGI/FCGI module option with nginx, Apache, etc. ?

If not then I think it makes sense to start from it. Your module will handle data/json request and the rest will be handled by HTTP server.

链接地址: http://www.djcxy.com/p/60698.html

上一篇: 与服务器程序定向?

下一篇: > C ++后端通信