问题
I'm brand new to c++, so my vocab's probably off.
I currently make 100% ajax sites but want to work in websockets to autoupdate relevant clients.
I'm using fastcgi++ and websocket++. I'd like to serve all data via the websocket but update the database via ajax calls. My problem comes in when I want to have the ajax page trigger the websocket.
I've read about sockets, fifo, and pipes, but I'm not sure which one is ideal for this situation.
For two c++ programs, one ajax & one websocket, on the same linux box, how can the ajax program safely and asynchronously call a function in the websocket program?
回答1:
Have both programs talk to the same database. If you need some way to "throw a dart" at the other to notify it to check the database, you can use shared memory or a pipe. Sending one byte through the pipe is sufficient.
来源:https://stackoverflow.com/questions/15303919/how-2-c-programs-call-each-others-class-functions-on-same-linux-box