From: Darren Garvey (lists.drrngrvy_at_[hidden])
Date: 2007-08-18 14:50:06
On 17/08/07, Jean-Christophe Roux <jcxxr_at_[hidden]> 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).
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
// 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);
// This is in the examples: http://tinyurl.com/27vnnx
boost::thread t1(boost::bind(&cgi::fcgi_threadpool_server::run, server);
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk