Page 2 of 2

Re: Help. about fascgi.thanks you.

Posted: Sat Jan 23, 2010 3:12 pm
by ruyi7952
Hi Trond.

thanks for your reply.

socket??? then are fastcgi_app mode.

I want to write a stdio mode fastcgi,stdio mode needed socket too????

please.
The I/O Libraries
The FastCGI Software Development Kit that accompanies Open Market WebServer 2.0 includes I/O libraries to simplify the job of converting existing CGI applications to FastCGI or writing new FastCGI applications. There are two libraries in the kit: fcgi_stdio and fcgiapp. You must include one of these header files in your program:





fcgi_stdio.h
fcgiapp.h
The fcgi_stdio library is a layer on top of the fcgiapp library, and we recommend strongly that you use it, both for converting existing CGI applications and for writing new FastCGI applications. The fcgi_stdio library offers several advantages:





Simplicity: there are only 3 new API calls to learn
Familiarity: If you are converting a CGI application to FastCGI, you will find few changes between CGI and FastCGI. We designed our library to make the job of building a FastCGI application as similar as possible to that of building a FastCGI application: you use the same environment variables, same techniques for parsing query strings, the same I/O routines, and so on.
Convenience: the library provides full binary compatibility between CGI and FastCGI. That is, you can run the same binary as either CGI or FastCGI.
The fcgiapp library is more specific to FastCGI, without trying to provide the veneer of familiarity with CGI. This manual describes the fcgi_stdio library; the fcgiapp library is documented in the header files that accompany the development kit.
Example 1: TinyFastCGI
Here is a simple example of a responder FastCGI application written in C:

Code: Select all

#include "fcgi_stdio.h" /* fcgi library; put it first*/
#include <stdlib.h>

int count;

void initialize(void)
{
  count=0;
}

void main(void)
{
/* Initialization. */  
  initialize();

/* Response loop. */
  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"));
  }
}

printf() it's not stdin/stdout function???

Re: Help. about fascgi.thanks you.

Posted: Sat Jan 23, 2010 3:58 pm
by Foz
Please read Trond's post:
Trond wrote:When you use fastcgi in C, it replaces the default printf() with a special fastcgi function.
It changes what you write. You need to get the fastcgi function and use that directly as replacing the Print() function in PureBasic automagically on compile isn't possible.

Re: Help. about fascgi.thanks you.

Posted: Sat Jan 23, 2010 4:03 pm
by ruyi7952
thanks foz.

where it's Trond's post???? :wink:

Re: Help. about fascgi.thanks you.

Posted: Sat Jan 23, 2010 6:59 pm
by Trond
I want to write a stdio mode fastcgi,stdio mode needed socket too????
I think so.