From: Brian Candler Date: 2007-03-14T05:59:55+09:00 Subject: Re: Bi-directional pipe? On Wed, Mar 14, 2007 at 05:29:16AM +0900, Rob Biedenharn wrote: > On Mar 13, 2007, at 4:15 PM, Brian Candler wrote: > >Is there any standard Ruby way of creating a bidirectional pipe or > >socketpair? > > > >I want to pass a single IO-like object around, but to be able to > >both read > >and write from the other end. (What I'm actually trying to do is to > >put a > >facade around Net::SSH so that the command channel can be passed in > >as a > >proxy to Net::Telnet, but I can think of other uses of this) > > > >IO.popen(..., "w+") does make such a bidirectional pipe, but as far > >as I can > >see only for communicating with a child process. > > > >Any ideas? > > > >Thanks, > > > >Brian. > > rd, wr = IO.pipe > > comes to mind. That's a *unidirectional* pipe. At least, all the rdoc stuff says that one end is a reader and the other end is a writer.