![]() |
Home | Libraries | People | FAQ | More |
You can just allocate a portion of a shared memory segment, copy the message to that buffer, send the offset of that portion of shared memory to another process, and you are done. Let's see the example:
#include <boost/interprocess/managed_shared_memory.hpp> #include <cstdlib> //std::system #include <sstream> int main (int argc, char *[2] "MyName"[]) { using namespace boost::interprocess; if(argc == 1){ //Parent process //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MyName"); } ~shm_remove(){ shared_memory_object::remove("MyName"); } } remover; //Create a managed shared memory segment managed_shared_memory segment(create_only, "MyName", 65536); //Allocate a portion of the segment (raw memory) managed_shared_memory::size_type free_memory = segment.get_free_memory(); void * shptr = segment.