cpp-fcgi provides a thin object oriented wrapper around the thread-safe fast CGI library API. The library is rather object oriented to begin with, so for the most part it just provides member methods which wrap the object methods from the C library. There isn't any added functionality, it just makes code slightly more readable.
Below is a simple example of it's usage:
#include <cpp-fcgi.h>
#include <iostream>
int main( int argc, char** argv )
{
if( argc < 2 )
{
std::cerr << "Usage: " << argv[0] << " [SOCKETPATH]|:[PORTNUMBER] \n";
return 0;
}
if( result != 0 )
{
std::cerr << "Failed to initialize FCGI" << std::endl;
return 0;
}
result = socket.
open(argv[1],100);
if( result < 0 )
{
std::cerr << "Failed to open socket: " << argv[1] << ", error: "
<< result << "\n";
return 0;
}
if( request.
init(socket) != 0 )
{
std::cerr << "Failed to initialize the request\n";
return 0;
}
int reqNum = 0;
while( true )
{
if( result != 0 )
{
std::cerr << "Failed to accept request: " << result << std::endl;
break;
}
request.
out() <<
"Content-type: text/html\n"
<< "\n"
<< "<title>FastCGI Hello! (C, fcgiapp library)</title>"
<< "<h1>FastCGI Hello! (C, fcgiapp library)</h1>"
<< "Request number " << ++reqNum
<< " running on host <i>"
<< "</i> Process ID: "
<< getpid()
<< "\n";
}
}