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 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?

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.

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

Gennady.