On Thu, 17 Jun 2004, Phil Tomson wrote:

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

Umm, if I understand things aright, if you open a named pipe in 
read/write, mode do a write then a read, I'm afraid you just chatting to 
yourself!

eg.
mkfifo foofi
ruby -e 'open("foofi", "r+") {|i| i.syswrite( "as");puts i.sysread(2)}'
as

Solution you need to open _TWO_ named pipes, one for reading, one for 
writing.

Also note I used sysread and syswrite others buffering and screw up your 
life.

> ....yeah, I should probably be using sockets, but this is a sort of
> 'legacy' system.

So now you have two IO's to watch, you can use a "select" to cope with 
that, _or_ Threads. Did you know (Matz may have changed it but this is 
the way it was when I last looked) all the threading stuff all wends it 
way down into a single select lurking deep within the bowels of ruby?

ie. Ruby Thread based app === "select" event based app in a very deep 
sense.

Ruby threading is just simpler.

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand

The universe is absolutely plastered with the dashed lines exactly one
space long.