5

I've a project that has a program written in C++ (that always has to run) and a Apache web server with PHP on a Windows PC. Now I want to send parameters retrieved from clients in PHP to the C++ program and get an answer back, but I can't figure out how to do it.

I've looked at exec() and shell_exec() in PHP, but they can only execute programs, I want to call a method in C++ and send the return value back to PHP.

Is the best way to temporary store the results in a file or do you have any better ideas?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
bpn
  • 53
  • 2

2 Answers2

4

Open a socket or use some other OS-provided interop mechanism. (I'd stick with TCP/IP sockets.)

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
4

Another solution is to use named pipes.

Here are a tutorial how to: http://my.opera.com/zomg/blog/2007/08/29/php-and-named-pipes

another answer: Interprocess Communication using Named Pipes in C# + PHP

making a named pipe for php http://www.phpbuilder.com/manual/function.posix-mkfifo.php

Community
  • 1
  • 1
Lucian
  • 3,407
  • 2
  • 21
  • 18
  • 1
    Note that it is not possible to make a named pipe from PHP on Windows. Reading and writing to an existing pipe should work fine, however. – ladenedge May 12 '12 at 02:48