
Hi Jean-Christophe, On 17/08/07, Jean-Christophe Roux <jcxxr@yahoo.com> wrote:
Darren Garvey wrote:
Hello all,
Hello Darren,
Here is basic use case. I have this ajaxian website with a button that, on a click, calls a php script taking a couple of POST parameters and returning a string. I suspect that C++ would nicely speed up the process. What would be the best use of your library? Of course, I worry about the time to start the process.
Well, FastCGI is ideal for AJAX functions. It was supposed to be implemented by now, but unfortunately you'll have to wait a little bit longer. :( The structure of the library has been mostly worked out, so I'm '85% sure' that the following code will work, eventually. Note that the following program is basically a backend daemon and will handle an arbitrary number of requests (you'll probably limit this with your server though). #include <boost/cgi/fcgi.hpp> #include <boost/thread.hpp> #include <boost/bind.hpp> int sub_main(cgi::fcgi_request& req) { cgi::reply rep; // use this to write to the client // First, check the client didn't send us too much data if (req.content_length() > 2048) { return req.close(cgi::http::bad_request, 1); } rep<< "This will be output to the client" << "the POST variable 'post_var_1' has a value" << req.meta_post("post_var_1", true); // the 'true' above tells the request to read and parse the client's post data until // either 'post_var_1' is found or the end of POST data is reached. rep.send(req); // return the response to the client. return req.close(cgi::http::ok, 0); } int main(int,char**) { // This is in the examples: http://tinyurl.com/27vnnx cgi::fcgi_threadpool_server server; boost::thread t1(boost::bind(&cgi::fcgi_threadpool_server::run, server); t1.join(); return 0; } Regards, Darrem