Re: simple c fcgi client to talk to fastcgi process?
Basile STARYNKEVITCH <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
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 ___________________________________ fastcgi-developers mailing list http://fastcgi.com/fastcgi-developers/