在应用程序中使用 CGI 二进制文件

发布于 2024-08-16 21:49:44 字数 167 浏览 1 评论 0原文

应用程序如何与 CGI 二进制文件交互?例如,假设我的应用程序在 Windows 上运行,并且想要在 Web 服务器的上下文中调用 PHP.exe 二进制文件。我该怎么做?通过传递某种命令行参数?我正在使用 C++,如果有帮助的话。

注意 - 我知道如何调用进程等。我只是想知道 CGI 如何适应这一点。

How would an application interface with a CGI binary? For example, say my app is running on Windows and wants to invoke the PHP.exe binary in the context of a web server. How would I do this? By passing some sort of command line arguments? I am using C++, if that helps.

NOTE - I know how to invoke processes and such. I just want to know how CGI fits into this.

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

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

发布评论

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

评论(1

停滞 2024-08-23 21:49:45

CGI 接口的工作原理如下:当请求到来时,Web 服务器运行一个进程,HTTP 输入(又称 POST 数据)通过 stdin 提供给进程,生成的内容和标头通过 stdout 发出。服务器变量通过环境传递。

现在,你的问题还不够清楚。您是否有想要从程序调用的符合 CGI 的本地二进制文件?或者您想在 Web 服务器上的某个位置调用符合 CGI 的二进制文件?

在前一种情况下,使用常规的进程创建方式(CreateProcess、fork/exec),并重定向 I/O 管道。在后一种情况下,使用 HTTP 客户端库(curl、WinInet)发出 HTTP 请求。

The CGI interface works as follows: when a request comes, the Web server runs a process, the HTTP input (AKA POST data) is supplied to the process via stdin, the generated content and headers are emitted via stdout. Server variables are passed via environment.

Now, your question is not clear enough. Do you have a CGI-compliant local binary that you want to invoke from a program? Or do you want to invoke a CGI-compliant binary somewhere on a Web server?

In the former case, use regular means of process creation (CreateProcess, fork/exec), with I/O pipes redirected. In the latter case, use a HTTP client library (curl, WinInet) to issue an HTTP request.

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