Shared memory for data transfer

Community Forums/General Help/Shared memory for data transfer

Heliotrope(Posted 2015) [#1]
Hi there, what is the best way to implement interprocess communication. Is shared memory the best way to do it and which program out of Blitz Basic, BlitzMax or C is best for IPC?


Matty(Posted 2015) [#2]
What kind of data do you wish to communicate?

Knowing the purpose helps when giving advice.


Heliotrope(Posted 2015) [#3]
Small stuff like intergers and strings at first, then move onto the composite data.


Matty(Posted 2015) [#4]
I think there are some windows apis in the code archives for this. Do a search for rtlmovememory (I think thats what it was....been a while)


Heliotrope(Posted 2015) [#5]
Thanks for that Matty - (RTLcopymemory?) Also the way I understand it, Blitz complies to C in a way that looks after the Garbage collection for you. Does that mean that mean that it is secure in the way of reducing the likelyhood of a buffer overflow attack doing dammage?


Brucey(Posted 2015) [#6]
There is a cross-platform BlitzMax module which does IPC using Boost's Interprocess library.


Heliotrope(Posted 2015) [#7]
Hi Brucey, if this is the right mod(https://code.google.com/p/maxmods/source/browse/trunk/boost.mod/src/boost/interprocess/ipc/message_queue.hpp?r=1151), where can I find the documentation? Also is it possible to convert from Blitzmax/plus to C or should I just stick to blitzmax/plus?


Brucey(Posted 2015) [#8]
The BlitzMax module source is available here : https://github.com/maxmods/bah.mod/tree/master/interprocess.mod

If you are intending on doing IPC stuff in C/C++ (and not actually using BlitzMax), you may prefer to use Boost interprocess itself : http://www.boost.org/


Heliotrope(Posted 2015) [#9]
Hi Brucey, since I have no clue when it comes to C, is there a way to convert blitz to C? And is there anything that explains the IPC mod?


Brucey(Posted 2015) [#10]
I'm not sure why, if you don't know C, you need some conversion to C?

The glue (glue.cpp) code (that connects BlitzMax to Boost Interprocess) is C++. There are some examples of BlitzMax usage in the examples folder provided - You can browse everything from that first link I provided.

The examples themselves are pairs of files (named_mutex/named_mutex2 and shared_memory/shared_memory2). You would run them both at the same time to see the effect of the IPC.

BlitzMax generates intermediate assembler, not C.


Heliotrope(Posted 2015) [#11]
Hi Brucey, my understanding is that DLL's are writen in C and I want to use an include command or a DLL to recycle the code so that many programs can share data.


Brucey(Posted 2015) [#12]
Cool. What language are you writing your "programs" in?
If it is a "Blitz" language, you don't need DLLs, as everything you need can be compiled into each binary.


Heliotrope(Posted 2015) [#13]
I am programing in the blitz languages and what do you mean by compiling to binary?