I actually don't know whether I am asking a proper question. Let me describe my problem first.
End user <-1-> web server (by PHP) <-2-> an internal process (by C or C++) <-3-> an external hardware
The 1 should be something like ajax request.
The 2 should be something like inter-process communication.
The 3 should be uart RS232 communication.
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.
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.
The webserver will wait until the c/c++ program returns (via IPC again), and then forward the result back to the end user.
Since the webserver has no memory, so there can't be any asynchronous things (as far as I understand).
I can think of a simple way which is via file or database. The webserver continuously reading files or database for reply.
But I don't really think this is a good way because it causes wasting of server CPU cycles.
If I can tolerate some delays, well, it depends, but I think several seconds of delay at user side is ok to them.
Can you suggest me some nice ways of IPC to achieve my purpose?
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 & 3), please also share your 2cent.
Hope I asked my question clearly.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…