Communication between two binaries

Hi there,

I hope this is not a double. I have already searched the web, and came across ABIs, APIs, exposed functions, libraries and the like, but nothing seems to really match what I am looking for. Perhaps I just need the right "buzzword", or maybe I am just missing some basics in the following context.

Let's say I have two c++ binaries, "dothis" and "dothat". Both can be considerd to run permanently on a linux system, for simplicity lets just assume both binaries have a while(1) loop that is doing its thing forever.

Now, how is it done correctly if I want the binary "dothat" have access to a function and/or data/variables that exist in the "dothis" binary??

Of course I could save the date to the SDcard (RPi) and read it with the other program, but I'd like to take advantage of the fact that the stuff I want to get is anyway in memory. Also transmission via some local port would be possible, but all this is not what I really want.

I am thinking of some way to "expose" or "share" a variable and/or function, such that the other binary can call/use it. Perhaps this is like writing a library that can be added to the "dothat" binary that tells it about the stuff inside the "dothis" binary. But that still does not really explain me how I can "expose" something from inside the "dothis" binary.

This seems to be a pretty standard thing to do I believe, and if anyone could give me a push in the right direction that would be great. Ideally some tutorial or example, but also the correct "buzzwords" may help already to search for it properly.

Thanks in advance. San
The term you are looking for is IPC (or interprocess communication). There are many ways for two processes to communicate with each other in the manner you desire. Usually they're os-specific, however using (unix) sockets is generally a good way to get two programs communicating.

Edit: In addition to looking up sockets, you may also want to read about select (or if you're on linux, epoll)
Last edited on
Thanks uplime. I will do some research using that "keyword" and see if that puts me on track. You response is very much appreciated.

Edit: It seems that was the right "entry point". There are obviously various ways, some more simple, and more complex ones.

I think in my case the "shared memory" approach is what I will be using/testing now.

In case someone else is looking for something similar, you may want to look here:

And here is even a minimal example:

And for more complex ones, there is also a Boost lib (which I was already expecting but didn't know what to look for):
Last edited on
Topic archived. No new replies allowed.