[RESOLVED] How can I implement bidirectional communication between two processes?
Hello,
I have two command line apps, one of them is multithreaded. I need to implement a bidirectional communication between them. Currently I can do
Code:
ProgramA 1> ProgramB
for the first programA to direct output into ProgramB, however I also need ProgramB to send messages to ProgramA.
Can you give me ideas, maybe samples, how to implement it in a easiest way. Thank you!
btw, I am on Ubuntu.
EDIT: I'd rather not to use third party libraries, Boost, etc.
Re: How can I implement bidirectional communication between two processes?
So, there are pipes, FIFOs, message queues, semaphores, and shared memory.
Semaphores and shared memory are probably an overkill. Pipes are unidirectional so I'd need two of those, then I can use also use FIFO or message queues. I do not have experience with any of those. What would be an easiest way? I just need two apps to exchange text messages. I would also like for debugging purposes for a program to spit the output into stdout and read from stdin if I run any of the two programs on their own.
Thank you.
Re: How can I implement bidirectional communication between two processes?
Re: How can I implement bidirectional communication between two processes?
Right, also sockets. Would it be the easiest way comparing to other methods, the easiest for debugging messages and easiest for implementing?
Re: How can I implement bidirectional communication between two processes?
a semaphore is not going to pass a message. It's only going to let you know the availability of a resource.
I usually use shared memory. It may be overkill in your instance (I don't know but you said it was), but it does give you flexibility should you requirements change.
Re: How can I implement bidirectional communication between two processes?
Shared memory & semaphores are probably the most difficult to implement, I want to use pipes or FIFO.
Re: How can I implement bidirectional communication between two processes?
Check this post (from a long time ago). The example assumes though that your first program spawns the second one.
Re: How can I implement bidirectional communication between two processes?
Quote:
Originally Posted by
treuss
Check
this post (from a long time ago). The example assumes though that your first program spawns the second one.
thanks for the link.