I need to send a string from one process to another using Boost. Actually I'm trying to create a firebreath plug-in (firebreath uses Boost in its backend) which should be capable of sending messages to another firebreath plugin. I think it should be some event mechanism; when the sender plugin sends the string, an event sh开发者_如何学Goould be fired in the receiver plugin. What is the best way to do that?
some have suggested using boost::ipc, others have warned that boost::ipc doesn't work well on windows. I haven't tried boost::ipc myself, so I don't know. One option would be to use boost::asio to create a local socket (socket on localhost) and start a thread to listen on one side; another option on windows would be to use named pipes. I've used named pipes with good success in the past.
The main thing to remember is that you can't block the main thread in FireBreath -- if you do it'll lock up the browser process or best case cause a dialog to pop up asking the user if they want to kill your plugin. Instead, create a second thread to handle the listener and then call FireEvent when something happens that your page needs to know about.
See also Is Boost IPC any good?
精彩评论