communicate c program and php

后端 未结 4 1512
悲&欢浪女
悲&欢浪女 2020-12-03 09:14

I want to have a web page (written in php because it\'s what i know) that displays an input value. I want that value to be passed to a c programa that\'s already running.

4条回答
  •  旧时难觅i
    2020-12-03 10:14

    You can use a named pipe.

    1. Once the external program starts running (or before that), you make sure the named pipe exists. See mkfifo.
    2. Open the pipe for reading in the external program (just like you open a regular file).
    3. Start reading the pipe. By default, the program will block until it has data to read.
    4. Open the pipe for writing in the PHP script (again, just like you would open a regular file).
    5. Write data to the pipe. The external program will now get this data.

提交回复
热议问题