FastCGI, SCGI,

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

I am watching FastCGI protocol and it looks annoying. This reminds me of what I had to do in class when I converted ASCII to UTF-8 and vice versa (it seemed useless, but maybe it wasn’t).

I found a large library written in PHP, where I could just run php-cgi -b localhost:8888 and start talking to it. Obviously, I would like to in C.

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

Also, how exactly do I use SCGI? There is virtually no documentation (that I can find, anyway). What socket am I connecting to? Where can I send requests?


In addition, php-cgi is only for PHP, so how does it work for Perl, Python, etc.

Thanks again.

+6
source share
1 answer

Mario said (in the comments on the question):

  • There are several libraries on the FastCGI homepage. http://fastcgi.com/drupal/node/5 . The developer kit must include a server.
  • It also includes a client implementation. http://fastcgi.com/devkit/doc/fcgi-devel-kit.htm
  • SCGI http://python.ca/scgi/protocol.txt is extremely easy to implement even without reference code.
  • You need a SCGI client that works like a deamon and that accepts socket connections on a negotiated port (4000 or 5000 seems normal).
  • SCGI is no different from FastCGI. Each language will need its own daemon, you can run several. And accepting CGI requests is pretty much what they do. The only difference is the socket and header format instead of the CGI stdin pipe and env.

To this I would like to add: CGI (this is what the question is) is different from FCGI and SCGI in their working models. It is quite easy to take one for others. Fortunately, it seems that Preetam has asked for FCGI and SCGI.

+5
source

Source: https://habr.com/ru/post/886204/


All Articles