|
-
March 29th, 2012, 12:08 PM
#1
[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.
Last edited by vincegata; March 29th, 2012 at 12:12 PM.
-
March 29th, 2012, 12:36 PM
#2
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.
-
March 29th, 2012, 02:34 PM
#3
Re: How can I implement bidirectional communication between two processes?
-
March 29th, 2012, 02:37 PM
#4
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?
-
March 30th, 2012, 08:03 AM
#5
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.
"Effective teaching is the essence of leadership..."
"There is no substitute for a carefully thought-out design."
If you have found this post to be useful, please Rate it.
-
March 30th, 2012, 08:06 AM
#6
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.
-
April 2nd, 2012, 10:34 AM
#7
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.
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf
Premature optimization is the root of all evil --Donald E. Knuth
Please read Information on posting before posting, especially the info on using [code] tags.
-
April 2nd, 2012, 10:37 AM
#8
Re: How can I implement bidirectional communication between two processes?
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|