In article <40D0D1CA.4080408 / tonesoft.com>, Gennady  <gfb / tonesoft.com> wrote:
>Phil Tomson wrote:
>
>> I've got two programs which need to communicate (which eliminates 
>> un-named pipes).  Information needs to be sent in both directions such 
>
>The mere fact that 2 independent programs need to communicate does not 
>eliminate un-named pipes. A third program may be written to create 
>un-named pipes, fork 2 processes, redirect file descriptors accordingly 
>in both of them and then exec your programs in those processes. It may 
>also be possible to exec one program in the original process.

That's an idea, but in this case it probably won't work.  One of the 
programs is usually started much earlier than the other and stays up much 
longer (the other program might be invoked and finish several times while 
the first one is running).

>
>> that one program (say it's called the master) sends a couple of bytes 
>> to and then waits for a response from the other program (say it's called the 
>> slave) and so on.  It looks like if you open the pipe (or FIFO file) from 
>> both sides in read/write mode that the pipe is opened non-blocking so what 
>> ends up happening is that the side which sends first just keeps sending and 
>> doesn't wait for a response.  
>> 
>> ....yeah, I should probably be using sockets, but this is a sort of 
>> 'legacy' system.
>> 
>> phil
>> 
>
>How do you specify that FIFO file to your programs? Do they know it by 
>name and open it explicitly or do they expect certain file descriptor to 
>point to the file on program startup?
>

By name.

>You may end up with 2 FIFOs, as if you use only one FIFO a process that 
>wrote to the pipe and then started reading from it will compete with the 
>other process to which the data was intended. I would also think about 
>using a pty for this as it is truly bi-directional.

Yes, that's the conclusion that I've come to: I need two FIFO files.

>
>If you need more help, please provide details on your programs.

Sorry 'bout that.  The current code is in C so i didn't want to post it 
here (also it doesn't work).  I'm only going to be using Ruby on one side 
just to do a bit of debugging...

Phil