From: ara.t.howard@... Date: 2006-04-14T01:44:42+09:00 Subject: Re: IO stream help On Fri, 14 Apr 2006, Lon Baker wrote: > Logan Capaldo wrote: >> On Apr 13, 2006, at 11:46 AM, Lon Baker wrote: >> >>>> >>>> => nil >>> >>> Thank. But no luck. >>> >>> It seems to hang waiting for input. >>> >> >> And you don't want it to block for input? Are you trying to use >> asynchronous IO or something? > > Yes it needs to be asynchronous. > > The application is listening and responding to an external application. > > It sits there listening for commands, processes them and responds with > its own commands. > > Would IO.popen or pipe be something to look at? you need something like Thread.new(cmd) do |cmd| IO.popen(cmd, 'r+') do |pipe| pipe.each do |line| case line when /request a/ pipe.puts 'response a' when /request b/ pipe.puts 'response b' end end end end ... do other stuff while thread runs if you don't have 'other stuff' to do there's no point in making it async of course though... regards. -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama