How do I write a back end App for a Web Server using C++?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
How do I write a back end App for a Web Server using C++?
I am an inexperienced programmer (hobbyist) trying to write a program in C++ that a web server can interface with. The application runs continuously like a daemon or service, and the web server should act as a front end to it (i.e. I am writing a back end application for a web site). I can write the application but do not know how to add the necessary interfaces for it to talk to the web server/site. Ideally, I was targetting something that would work with the Apache http server.
Any suggestions anyone? Is there a common interface scheme that will work under Windows and LINUX for Apache?
I don't think CGI will work. As far as I understand CGI calls a program; which in turn runs, does some processing, and then exits. In my case the program is already running (before the request is made) and should continue running when the request is finished. I want the web request to interact with it, sending it questions and getting back responses.
I chose C++ since its what I know, and I can implement the application fairly easily in it (minus the interface for the web server, which is what I want to do now).
My analysis: the web server is a process which uses CGI to extend its capabilities by launching a child process and passing information to it, either on it's commandline (GET requests) or by piping to it's standard input (POST requests). The CGI is a process which can access whatever it needs to provide the service requested by the web server. It may do this by communicating with yet another process, such as a backend database, to use a common example. The methods used to do this are several, but in general, fall in the category of interprocess communication (IPC).
In your specific case, the C++ daemon needs to provide an IPC method which can be accessed by a CGI process. You can use one of the classic methods, such as shared memory or message queues, or you can use a socket-based approach using Unix sockets, or even Internet sockets. As I understand it, these are the most conventional methods available, and your specific requirements would dictate which is most appropriate.
--- rod.
Thanks theNbomr. Your post was exactly what I was looking for. Based on your suggestion I did some reading on IPCs and they have cleared up a number of misconceptions I had about sockets as well as suggest solutions that will work for me.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.