Link to home
Start Free TrialLog in
Avatar of deleyd
deleydFlag for United States of America

asked on

From PHP to C++?

I have a device on the internet. It has a MAC address. I would like to communicate with this device. The device accepts short commands, and returns data.

I would like to communicate with this device from a web browser. I can write HTML or PHP, or even CGI if necessary.

Problem is XmlHttpRequest doesn't allow cross domain access, and this device knows nothing about JSONP.

I do have a C++ program which can communicate with the device over the internet. It runs as a web server, and does a lot of low level socket I/O. It accepts user browsers connecting to it, via a certain port number, and it connects to the device, and it shuffles the data back and forth between the device and the user, formatting the data into HTML, sending the formatted HTML to the user's web browser.

Question: If I write a website in PHP, is there some way I can jump from PHP code into this C++ code?

Or, is there a way I can do this the other way around: run PHP code from within the C++ program? Right now the C++ program knows nothing about PHP or what to do with such files. We do have Apache installed. Not sure how to send it a PHP file for processing from a C++ program.
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deleyd

ASKER

Wow I didn't know I could code socket connections in PHP. Can you direct me to some PHP documentation on that?
Avatar of deleyd

ASKER

I found lots of documentation on PHP Socket programming. (Didn't know that was possible.)