Re: Windows NT, MFC, and FastCGI

Benjamin Gavin (
Wed, 03 Sep 1997 14:22:19 -0500

Message-Id: <>
Date: Wed, 03 Sep 1997 14:22:19 -0500
From: Benjamin Gavin <>
Subject: Re: Windows NT, MFC, and FastCGI


Ok Everyone,
  Good news, and bad.  The bad news first, you cannot use the 
FCGI_Accept with MFC under NT 4.0, or at least I haven't figured out 
how.  The good news, I have gotten the 
FCGX_Accept(&in,&out,&err,&envp) to work.  This is a major pain, and 
I would suggest that we try to find a way to use FCGI_Accept.  The 
reason, as suggested by Bill Snapper, could be that MFC just blindly 
takes ahold and reassigns environment variables to seperate names, or 
to different places.  Either way it does not work.  Anyway, as long 
as you use the FCGX stuff, i.e. FCGX_Streams, ParamArrays, FPrintFs 
you are fine.
  If anyone is interested I have written a set of CGI utilities (in 
C++).  They are distributed in the public domain, freeware, all that 
stuff.  Anyway in that bundle are two sets of files, one for FastCGI, 
and one for regular CGIs.  I have tested parts of the libraries 
extensively under NT, and they perform very nicely.  I haven't 
experienced any major leaks, or problems, but of course none of this 
is under warranty of any kind.  If anyone is interested you can go to 
the following URL:

The CGI side of the libraries have been tested extensively under 
UNIX, but I haven't had a chance to try the FastCGI stuff there yet.  
If I can get more people using the libraries, then maybe I can get 
some help debugging them.  Please let me know if you have any 

Thanks for everyone's help,
Benjamin Gavin

At 08:12 AM 9/3/97 -0500, you wrote:
>  I have been working on this project, one piece of which uses 
>FastCGI, and one piece of which uses MFC.  I built the kit ran the 
>echo programs no problem, or at least with a little help.  The 
>environment variables changed from call to call, the process number 
>stayed the same, all that good stuff.  However, when I cut and 
>the code into a FastCGI app using MFC, it bombed miserably.  The 
>environment variables are no longer updating, and for CGI, that 
>basically makes the whole program worthless.  Here is what I did:
>1)  Downloaded files from
>2)  Ran build_no_shell.bat
>3)  Ran the echo_nt.fcgi test program, all is working fine.
>4)  Cut the code from the echo example, and pasted it into an 
>    MFC CGI program.
>5)  This did not work.  The environment variables don't get updated.
>  I don't have time to debug the FastCGI portion of this program, 
>I am at a loss as to what to do.  Is there something in MFC that is 
>causing these program to bomb??  Is it because using MFC forces you 
>to run Multithreaded??  I feel the the latter may be a problem.  I 
>going to look into it a little further, but like I said, I don't 
>that much time.  I assume, from what I have read, that the 
>libfcgi.dll file is compiled single threaded, and the cgi-fcgi.exe 
>as well.
>  Anyone have any other ideas??  Oh, I am using Microsoft VC5, under 

>Windows NT 4.0, with MFC being used in a shared dll.
>Version: PGP for Personal Privacy 5.0
>Charset: noconv
Version: PGP for Personal Privacy 5.0
Charset: noconv