Re: simple c fcgi client to talk to fastcgi process?

"smullen" <smullen-sFbbPxZDHXw0n/[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <000d01c668be$8e7d9e70$021ea8c0@home>
 

> -----Original Message-----
> From: Basile STARYNKEVITCH [mailto:[email protected]] 
> Sent: Friday, 21 April 2006 1:12 AM
> To: smullen
> Cc: fastcgi-developers-xGejAJT2w6yOE5Ap4OspEtHuzzzSOjJt@public.gmane.org
> Subject: Re: [FASTCGI] simple c fcgi client to talk to 
> fastcgi process?
> 
> Le Thu, Apr 20, 2006 at 11:52:48PM +1000, smullen écrivait/wrote:
> > Hi, I'm getting my head around fcgi and come up against a 
> brick wall.
> >  
> >  
> > I have fastCGIphp running on a socket ( i.e. php -b 
> /tmp/fastcgi.sock) 
> > and would like to "talk to it" directly in c and get a response.
> > 
> > In other words, send a simple "<?phpinfo();?>" (or script_filename) 
> > and get the reply.
> 
> You'll need to implement the whole FastCGI client protocol 
> stack. There is no library for this (the usual fastcgi 
> libraries are for fastcgi applications, which are FastCGI servers!).
> 
> I see other alternatives
> 
> 0. As mentioned above, code your FastCGI protocol stack in C, 
> you probably take some code fragments from some existing 
> FastCGI implementation in HTTP servers like mod_fcgi from 
> Apache or mod_fastcgi.c from Lighttpd) but be sure to respect 
> the code licence...
> 
> 1. switch to some simpler protocol, like SCGI (this is what I 
> did), which is less flexible that SCGI but simpler. I don't 
> know if there is a SCGI interface within PHP5 (like there is 
> FCGI for PHP), i.e. a way to run PHP interpreters as SCGI 
> servers. (However, i you can switch to Ruby Rails instead of 
> PHP, there is SCGI for Ruby!). You might perhaps use other 
> protocols like ICAP but they are not suited for this task...
> 
> 2. most simple: use the HTTP protocol (there are several HTTP 
> client libraries in C, for example CURL) and have, as usual, 
> an HTTP server between your FastCGI/PHP and your C 
> codeapplication. Eventually, you might run a smaller FastCGI 
> capable HTTP server for this only purpose -because a FastCGI 
> server can definitely have several clients, ie several HTTP 
> servers using it-, and accepting connextions only locally (or 
> on the local network). For example, you could run lighttpd 
> configured on port 8082 to accept only localhost connections 
> - from your C program.
> 
> The hardest to implement choice is 0, then maybe 1, then 2 
> which is easy.
> 
> The most performant choice (but does performance really 
> matters when using PHP?) is choice 0, then choice 1, then choice 2...
> 
> 
> -- 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
> email: basile<at>starynkevitch<dot>net
> aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net 
> 8, rue de la Faïencerie, 92340 Bourg La Reine, France


Thank you Basile. 

I've been playing with the C approach, and found this :
http://cryp.to/publications/fastcgi/

to be a very useful resource.


___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.