views:

478

answers:

2

Hi, i've installed Lighthttpd for windows and i'd created a simple program in c++ which uses fastcgi libraries. i'll post the code here...

#include "fcgi_stdio.h" 
#include <stdlib.h>
int count;
void initialize(void)
{
  count=0;
}
void main(void)
{
  initialize();
  while (FCGI_Accept() >= 0)   {
    printf("Content-type: text/html\r\n"
           "\r\n"
           "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
           "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
           "Request number %d running on host <i>%s</i>\n",
            ++count, getenv("SERVER_HOSTNAME"));
  }
}

I've spawned the fastcgi application in lighthttpd using the below configuration in lightttpd-inc.conf

fastcgi.server             = ( ".exe" =>
                               ( "" => 
                                 (
                                   "bin-path" => "D:\tinycgi.exe",
                                   "port" => 8080,
                                   "min-procs" => 1,
                                   "max-procs" => 1
                                 )
                               )
                             )

while sending a request using the browser the server is responding with this message in the console

2009-02-18 16:08:34: (mod_fastcgi.c.2494) unexpected end-of-file (perhaps the fa
stcgi process died): pid: 0 socket: tcp:localhost:8080
2009-02-18 16:08:34: (mod_fastcgi.c.3325) response not received, request sent: 1
024 on socket: tcp:localhost:8080 for /new/tinycgi.exe , closing connection

I think the fastcgi application is not spawned correctly.

Thank you, Varun

+1  A: 

First of all, main should return an int (not void). The problem is most likely that you didn't call FCGX_Init() and didn't initialize the request (with FCGX_InitRequest()) either. I wrote a function that parses the webservers data once, you can find the sample program and the library at http://yetanotherstenner.de/?q=node/11

tstenner
A: 

Hi I want to use lighthttpd and i want to create my module and add to lighthttpd plz help me and get me an example to do this.

Thanks

Amir