Reputation: 73245
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.
Upvotes: 0
Views: 216
Reputation: 61378
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.
Upvotes: 1