[ruby-talk:00213] Re: Get character with no wait

From: matz@... (Yukihiro Matsumoto)
Date: 1999-01-25 04:39:28 UTC
List: ruby-talk #213
In message "[ruby-talk:00212] Re: Get character with no wait"
    on 99/01/24, Gabriel <gabriel@devo.com> writes:

|That suppressed echo of input, but didn't solve the problem.
|Here is my code snippet, where s is a socket object:

Well, sorry.  I got the wrong point.

To avoid blocking, use threads.  Ruby's thread does not have any
porting problem, i.e. unlike Python nor Perl, where Ruby runs, threads
work, unless explicitly disabled by compile time option.

   Thread.start do
     loop do
       j = getc()
       s.putc(j) if j
     end
   end

   loop do
     m = s.getc
     putc(m)
   end

In This Thread