Thanks Ion, So as per your suggestion I am planning: 1) Get the handle on application 1 and pass it to application 2. 2) Application 2 (a C-lang process) do shm_open with same SHM name. mmap will give me pointer to start. 3) Using [ (char *) cast on mmap's void pointer ] and [ Increment by <handle> ] I will reach to actual data in shm and them read it by memcpy. *This is looking possible to me. Do you this this will work??* I have a small doubt here : 1) Handle are like offset, please correct me if I am wrong. Even I am inserting first element in SHM still it's coming as very high value. Why is it like this ?? Is it because we are using Tree (memory allocation) in boost shared memory ? OR we always start allocation from bottom of SHM ? Thanks, VijaySharma On Sun, Oct 8, 2017 at 2:45 PM, Ion GaztaƱaga via Boost < boost@lists.boost.org> wrote:
On 08/10/2017 10:18, vijay sharma via Boost wrote:
Once I have addr pointer, I am using memcpy to write in SHM.
You shouldn't pass raw pointers to another application, usually pointers are only valid inside a process and invalid outside it. Only the distance between the start of the shared memory and an address inside that shared memory is common for both processes.
Boost.Interprocess is not prepared to be used from a C application. Maybe you can try the following:
http://www.boost.org/doc/libs/1_55_0/doc/html/interprocess/m anaged_memory_segments.html#interprocess.managed_memory_segm ents.managed_memory_segment_features.segment_offset
Take an address of an position in shared memory in application 1 and call get_handle_from_address. Then pass the handle (usually of type size_t, an unsigned integer) using something like pipes or message queues, or a well-known shared memory address so that process 2 can access to it. Then the C application can map the shared memory, and add the base address of that shared memory, add the given handle/offset, and obtain the address of the wanted position in the shared memory for the second process.
In any case the code you've posted is invalid.
Ion
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman /listinfo.cgi/boost