Click to See Complete Forum and Search --> : Communicate with daemon.


jnmacd
August 26th, 2010, 02:42 PM
I plan on developing on a Single Board Computer that runs linux.
This board will run a daemon I create that does some controlling of the ADC functions on board and such.

This board will also host a web server for all the interfacing.
What do I need to do to make a PHP/CGI/etc... script be able to "talk" to this daemon? I also need for it to return data as well.

Sorry its so broad, but I just need a few pointers to get started.

jnmacd
September 3rd, 2010, 03:35 PM
I'll answer my own question.

On my linux application, I can use the mkfifo() command that will create a pipe.
PHP can read/write to this pipe just as if it was a file.

My linux application creates a new thread that has a while(true) block that runs a blocking function to read the pipe.

So... the 'infinite' loop thread will just sit there until data is written to that pipe, and then it can respond back.

Looking down the road a bit...
I will eventually create a website that will use AJAX methods to continuously poll for data from my daemon using the same php/pipe method.