views:

40

answers:

1

I have a daemon (written in C, but I assume it does not really matter) which outputs messages with printf, and can get input and do stuff with this input (again, not really important what, but he sends those messages to a different machine to be saved there in the DB).

My question, how can I make this daemon to be a stream in PHP, so I can hook the input/output of, for example, file_put_contents to this stream.

+2  A: 

Well, if it's a command that you want to execute, check out: http://us.php.net/manual/en/function.proc-open.php

If it's a process that's listening on a specific port (TCP communication), you can use: http://us.php.net/manual/en/ref.sockets.php

If you just want to be able to treat it like a file with all the built-in filesystem functions/classes (yourname://resource/resource.name), check out: http://us.php.net/manual/en/class.streamwrapper.php and http://us.php.net/manual/en/function.stream-wrapper-register.php

ircmaxell
+1, it sounds from his question that proc_open is the way to go.
Josh