0

I'm trying to exchange some small data between my two apps. This two apps located at the same PC, so all exchange happens inside this machine. At first, I thought maybe to use sockets for it, cause I had some small experience with it, but then I read some articles that said that it's not the best practice for it, cause all exchange happens at the same local machine, so don't need to use network solutions for such task.

And then I learned about anonymous pipes. From descriptions and examples it's looks liked the best for my case. But then turns out that this is all about parent-child model, so one(parent) app have to open another one(child) and pass data about pipe through constructor of child app. And this is not fit for my case, cause I want that my two apps would be totally independent, like they could close anytime separately, and then reopen again any time and after that continue data exchanging.

So how do you think, what would be the best for my case? Should I back to sockets? Or maybe anonymous pipes is also not always about parent-child model and maybe I just missed something?

1
  • I would suggest not using a lower layer than needed. There are plenty of message queues/busses that handle many of the complicated details about discovery etc.
    – JonasH
    Jan 26, 2021 at 16:13

1 Answer 1

1

Communication between processes requires that they know about each other. If they are in a parent-child relationship, it is easy for them to know about each other: the parent creates the child, and can inform the child of what their parent is.

But if they don't have a parent-child relationship, but rather a peer-to-peer relationship, then they need some way to know about each other.

Just like peers in real life, they can agree to rendezvous at a common point. On a computer network, the rendezvous could be a port address, or the name of a communications channel, which both processes connect to.

More concretely, on a single computer, many OSes provide abstractions for processes to rendezvous on. One in particular is named pipes, which are a bit like anonymous pipes, except of course they are not anonymous -- they have names. If two peer processes both know the same name, they can communicate on a named pipe with that name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.