C++ FastCGI "Hello World"

also see C++:

// Compiles with Visual Studio 2008 for Windows

// FastCGI - Hello world request counter
// running locally using the (free) Abyss Web Server

#include <sstream>  // manipulate strings (integer conversion)
#include <string>   // work with strings in a more intuitive way
using namespace std;

#include "libfcgi2.h" // Header file for libfcgi2.dll (linked with libfcgi2.lib)
#pragma comment(lib, "libfcgi2.lib") // Link the Dll

// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
int main( )
{
    FCGX_REQUEST Req = { 0 }; // Create & Initialize all members to zero
    int count(0);
    string sReply;
    ostringstream ss;

        FCGX_InitRequest( &Req, 0, 0 ); // FCGX_DEBUG - third parameter

         // Open Database

        while( FCGX_Accept_r(&Req) == 0 ) // Execution blocked until Request received
        {
            count++;
            ss << count; // Stringstream is a typesafe Integer conversion
            sReply = "Content-Type: text/html\r\n\r\n   Hello World " + ss.str();
            FCGX_PutStr( sReply.data(),   sReply.length(),   Req.pOut );
            ss.str(""); // reset the string stream object
        }

        // Close Database

    return 0;
}

// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Comments