FastCGI、SCGI、

发布于 2024-11-02 07:54:42 字数 485 浏览 0 评论 0原文

我正在用 C 语言编写一个 Web 服务器,我需要找到一种使用 CGI 在服务器端执行动态内容的方法。

我正在查看 FastCGI 协议,它看起来令人讨厌。它让我想起了我在课堂上将 ASCII 转换为 UTF-8 并转换回来时必须做的一些事情(当时看起来没用,但也许不是……)

我发现了一个用 PHP 编写的很棒的库,其中我可以启动 php-cgi -b localhost:8888 并开始与其通信。显然,我希望用 C 语言实现这一点。

如果有人能找到一个库(针对 FastCGI 客户端!),我将不胜感激。如果没有,那么我很乐意通过编写一个来为开源社区做出贡献。

另外,我到底如何使用SCGI?几乎没有任何关于它的文档(无论如何我都能找到)。我连接到什么插座?我应该将请求发送到哪里?


另外,php-cgi 仅适用于 PHP,那么 Perl、Python 等如何工作呢?

再次感谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的他你的她 2024-11-09 07:54:42

mario 说(在问题评论中):

  • FastCGI 主页上提到了一些库。 http://fastcgi.com/drupal/node/5。开发套件应包括服务器。
  • 客户端实现也包含在那里。 http://fastcgi.com/devkit/doc/fcgi-devel-kit.htm
  • SCGI http://python.ca/scgi/protocol.txt 非常简单即使没有参考代码也能实现。
  • 您需要一个作为守护进程运行的 SCGI 客户端,并且接受约定端口上的套接字连接(4000 或 5000 似乎很常见)。
  • SCGI 与 FastCGI 没有什么不同。每种语言都需要自己的守护进程,您可以运行多个。他们所做的就是接受 CGI 请求。唯一的区别是套接字和标头格式,而不是 CGI 标准输入管道和环境变量。

对此我想补充一点:CGI(这正是问题所要求的)在其工作模型中与 FCGI 和 SCGI 不同。很容易将一个人误认为其他人。幸运的是,Preetam 似乎要求使用 FCGI 和 SCGI。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文