bpn
bpn

Reputation: 53

How to communicate between C++ and PHP on Windows?

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?

Upvotes: 5

Views: 976

Answers (2)

Lucian
Lucian

Reputation: 3554

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

Upvotes: 4

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385295

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

Upvotes: 4

Related Questions