Two-way pipe

Hi!
How can I realize two-way pipe?

Regards
Victor V Ismakaev

Hello Victor,

vic ismakaev wrote:

How can I realize two-way pipe?

Maybe this link can help you:
http://rubycentral.com/book/ref_c_io.html#IO.pipe

Cheers,

···


Laurent

This may not be exactly what you are looking for, but maybe it is.

I have been looking for a way to create a read/write interface into
an application such that I can send it commands and read the results.

There seems to be a lot of people asking for this and I have read
a lot of responses on ruby-talk, but most of the threads end before
a final solution is obtained. So far, the link below looks the
most promising:

http://groups.google.com/groups?q=%2Bselect+%2Bopen3+group:comp.lang.ruby&hl=en&lr=&ie=UTF-8&group=comp.lang.ruby&selm=E13wxQm-0005FP-00%40ev.netlab.zetabits.co.jp&rnum=5

···

On Tuesday, 22 April 2003 at 18:50:23 +0900, vic ismakaev wrote:

Hi!
How can I realize two-way pipe?


Jim Freeze

There’s an old proverb that says just about whatever you want it to.

That’s an old post. I believe popen itself now supports bi-directional
communication natively.

a = IO.popen(“nroff -man”,“w+”)
Thread.new do
while line = gets
a.print line
end
a.close_write
end
while line = a.gets
print “:”, line
end
a.close_read

(This works under Unix for version 1.6.8, I seem to recall that it was fixed
for Windows in 1.7.something)

Regards,

Brian.

···

On Tue, Apr 22, 2003 at 07:06:38PM +0900, Jim Freeze wrote:

There seems to be a lot of people asking for this and I have read
a lot of responses on ruby-talk, but most of the threads end before
a final solution is obtained. So far, the link below looks the
most promising:

http://groups.google.com/groups?q=%2Bselect+%2Bopen3+group:comp.lang.ruby&hl=en&lr=&ie=UTF-8&group=comp.lang.ruby&selm=E13wxQm-0005FP-00%40ev.netlab.zetabits.co.jp&rnum=5

Thanks. This works great! Exactly what I was looking for.

···

On Tuesday, 22 April 2003 at 19:23:31 +0900, Brian Candler wrote:

On Tue, Apr 22, 2003 at 07:06:38PM +0900, Jim Freeze wrote:

There seems to be a lot of people asking for this and I have read
a lot of responses on ruby-talk, but most of the threads end before
a final solution is obtained. So far, the link below looks the
most promising:

http://groups.google.com/groups?q=%2Bselect+%2Bopen3+group:comp.lang.ruby&hl=en&lr=&ie=UTF-8&group=comp.lang.ruby&selm=E13wxQm-0005FP-00%40ev.netlab.zetabits.co.jp&rnum=5

That’s an old post. I believe popen itself now supports bi-directional
communication natively.

a = IO.popen(“nroff -man”,“w+”)
Thread.new do
while line = gets
a.print line
end
a.close_write
end
while line = a.gets
print “:”, line
end
a.close_read

(This works under Unix for version 1.6.8, I seem to recall that it was fixed
for Windows in 1.7.something)


Jim Freeze

There are people so addicted to exaggeration that they can’t tell the
truth without lying.