简体   繁体   中英

Using a php named pipe

SITUATION:

I have created a named pipe (in php ) with the following code:

$pipeFile = "/files/queue";
posix_mkfifo($pipefile,0666);

and now I would like to be able to send and extract data to and from the pipe with php pages (like readpipe.php , and put_in_pipe.php ).


QUESTION:

What function calls exist that I can use inside php files that can send data to the named pipe, and receive data from the named pipe?

Important: I already now how to send and receive data to and from the pipe via the terminal:

echo lol > /files/queue
cat /path/to/pipe 

What I dont know is how to do this in a php script. If I have a page called readpipe.php , and someone enters it, the page would need to have a function call to get the next message inside the pipe (just like cat ... would do for the terminal), and similarly, a page called put_in_pipe.php would need code that puts a message into the pipe (just like echo lol > ... ).

Any and all feedback is very much appreciated!

You can use any of file IO functions available in PHP, eg file_put_content / file_get_content to write to the named pipe and read from it, but I doubt it is what you want. Pipes can hardly be used in the multi-page scenario you described.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM