Pregunta

I am looking for an efficient way of responding to an http request. When a http request is received (apache/php webserver environment), I want to know if I can obtain a reference to php's response instance inside a c++ library method and write the output data directly to the response instance within C++ context.

¿Fue útil?

Solución

Normally, you'd simply redirect the request to your external C/C++ program through mod_fastcgi, processs it completely in your program and write the repsponse to the client.

If not possible, you could include the program output into the generated web page by accessing your program from Apache as a server side include (SSI).

From PHP, you can also perform a system call to the external program and process the returned output as shown in the link.

Some simple C examples are provided in the fastcgi documentation.

To write a PHP extension in C/C++ (here and there) and make that work in Apache (through mod_php) is possible, but is considered rocket science and therefore discouraged ;-)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top