title: What is a good Inter-Process Communication method between C and PHP in Linux
body: <p>I actually don't know whether I am asking a proper question. Let me describe my problem first.</p>
  
  <p>End user &lt;-1-> web server (by PHP) &lt;-2-> an internal process (by C or C++) &lt;-3-> an external hardware</p>
  
  <p>The 1 should be something like ajax request.
  The 2 should be something like inter-process communication.
  The 3 should be uart RS232 communication.</p>
  
  <p>The end user will request to change some settings on the hardware, then the request will propagate to the hardware. The hardware replies successful or failed, then the result will propagate back to the user. The hardware reply delay can be within 1 second.</p>
  
  <p>So when the webserver receives ajax request from end user, it will hold and send an IPC request to the c/c++ program. The c/c++ program will send via UART and hold and wait for hardware to reply. For UART part, there's asynchronous uart model, so the c/c++ program won't need to continuously wait for the UART. </p>
  
  <p>The webserver will wait until the c/c++ program returns (via IPC again), and then forward the result back to the end user.</p>
  
  <p>Since the webserver has no memory, so there can't be any asynchronous things (as far as I understand). </p>
  
  <p>I can think of a simple way which is via file or database. The webserver continuously reading files or database for reply.</p>
  
  <p>But I don't really think this is a good way because it causes wasting of server CPU cycles.</p>
  
  <p>If I can tolerate some delays, well, it depends, but I think several seconds of delay at user side is ok to them.</p>
  
  <p>Can you suggest me some nice ways of IPC to achieve my purpose?</p>
  
  <p>And, if you think there's a better solution (than my description above) for the whole process or any specific link (including link 1, 2 &amp; 3), please also share your 2cent.</p>
  
  <p>Hope I asked my question clearly.</p>
  
  <p>Thanks.</p>