Hello,
I have an application which runs on a single linux box, with a C++ backend server and a web-based front end, with apache also running on the local server.
I'm using PHP to communicate with the C++ backend, and would like to just connect to the C++ server once, and have bilateral communication as follows:
1. As the user carries out actions on the web front end, just use fwrite to communicate with the backend on the persistent socket.
2. Have a small javascript routing using timeout to regularly call a php routine to process any (asynchronous) messages the server might send us on the socket. This is the primary reason I want the socket to stay connected.
I should point out that the volume of traffic is pretty low - this is a "control" application for some hardware, but we're talking a few kbytes an hour.
The problem I'm encountering is that I cannot find a way to pass a socket object between one call to a PHP script and another. The PHP sessions paradigm works great for passing integers and strings for example, but doesn't work for passing a socket object. I can understand why that would be the case, but does anyone have any hints as to how I might achieve what I'm trying to do?
I like PHP and I am very familiar with sockets, so that's why I'm trying to do it this way, but I'm not particularly wedded to either if someone has a suggestion for a better approach. I *DO* need to use a browser front end for other reasons.
Any help much appreciated.
Chris Hegarty