The FastCGI-savvy binaries are extensions of standard Tcl, and are intended to replace your existing Tcl installation. There is no need to maintain two versions of Tcl: the version that we supply will work fine when invoked from a shell or a CGI program. There are also directions in the developer's kit for how to make your own FastCGI-savvy Tcl, if you need a version for some platform that we don't supply.
In many cases, you can convert a Tcl script from CGI to FastCGI by adding a few lines of code to an existing script. For more complex scripts, you may also need to rearrange some existing code.
Then, you have to divide FastCGI scripts into the following two sections:
while {[FCGI_Accept] >= 0 } { # body of response loop }The
FCGI_Accept
call returns 0 whenever a client requests the FastCGI script. Otherwise, the FCGI_Accept
call returns -1.
#!fcgi-savvy-tcl set count 0 # Response Loop while {[FCGI_Accept] >= 0 } { incr count puts -nonewline "Content-type: text/html\r\n\r\n" puts "<title>FastCGI Hello! (Tcl)</title>" puts "<h1>FastCGI Hello! (Tcl)</h1>" puts "Request number $count running on host <i>$env(SERVER_NAME)</i>" }