开发者

How do I make a daemon into a stream in PHP

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 diffe开发者_StackOverflow社区rent 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜