I have an underlying C application driving some pretty intensive hardware. I'm currently designing a web interface for the device, the majority of it's function is to present status information to the user. So every second or so, update fields on the web page with pertinent information (temperature, framerate, yada yada...) The device runs linux and has apache. Current setup:
Here's where you come in... the goal is to take out the PHP middleman. What are the conventions (assuming they exist) for AJAX calls to C programs? Best practice?
Options (as far as I know):
Any insight appreciated. Of course, the best answer is quite possibly not even listed above. That's just the extent of my knowledge in this area. Thanks!
We have used the C library libwebsockets ( http://libwebsockets.org/ ) to communicate between JavaScript and a C++ application. In our case we send JSON to and from the C++ backend via websockets.
In your case you could take the same data that you currently send via Ajax and send it to the C program over the websocket. The C program can then generate the same JSON that the PHP program generates and send that back to the JavaScript, again via the websocket.
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.