Preetam Jinka
Preetam Jinka

Reputation: 329

FastCGI, SCGI,

I'm writing a web server in C, and I need to figure out a way to use CGI to execute dynamic content server-side.

I'm looking at the FastCGI protocol and it looks annoying. It reminds me of the bit twiddling I had to do in a class when I was converting ASCII to UTF-8 and back (that seemed useless then, but maybe it wasn't...)

I found a great library written in PHP where I could just start up php-cgi -b localhost:8888 and start communicating with it. Obviously, I'd like that in C.

I'd appreciate it if someone could find a library (for FastCGI clients!). If not, then I'm fine with contributing to the open source community by writing one.

Also, how exactly do I use SCGI? There's barely any documentation on it (that I can find, anyway). What socket do I connect to? Where do I send the requests?


Also, php-cgi is only for PHP, so how do things work for Perl, Python, etc?

Thanks again.

Upvotes: 6

Views: 2923

Answers (1)

Nam Nguyen
Nam Nguyen

Reputation: 1793

mario said (in the question comments):

  • There are a few libraries mentioned on the FastCGI homepage. http://fastcgi.com/drupal/node/5. The development kit should include the server.
  • The client implementation is included there for, too. http://fastcgi.com/devkit/doc/fcgi-devel-kit.htm
  • SCGI http://python.ca/scgi/protocol.txt is extremely simple to implement even without reference code.
  • You need an SCGI client that runs as deamon, and that accepts socket connections on an agreed port (4000 or 5000 seem common).
  • SCGI is no different than FastCGI. Each language would require its own daemon, you can run multiple. And accepting CGI requests is pretty much what they do. The only difference is the socket and the header format instead of a CGI stdin pipe and env variables.

To this I'd like to add: CGI (which is exactly what the question asks for) is different from FCGI and SCGI in their working models. It's quite easy to mistake one for others. Luckily, it seems like Preetam asked for FCGI and SCGI.

Upvotes: 5

Related Questions