< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Hi!
We tried to use "read_nonblock" in Windows environments using Ruby 1.8,
but no one (German Ruby-Forum) was able to do this with success. The
error message will always be "bad file descriptor".
An Example, which works with normal I/O. File "read_nonblock_test.rb":
-----------------------------------------------------------------
diener = File::popen("ruby read_nonblock_diener.rb", "r+") #
puts "diener=#{diener}"
puts ("a".."z").each { |buchstabe|
diener.puts buchstabe
diener.flush
erg =
case 3
when 1 then diener.read_nonblock(1)
when 2 then diener.read(1)
when 3 then diener.gets
end
break "nil erhalten." unless erg
print ":" + erg
$stdout.flush # nur aus optischen Gr?nden
}
puts "Fertig."
-----------------------------------------------------------------
File "read_nonblock_diener.rb":
-----------------------------------------------------------------
8.times {
erg =
case 2
when 1 then $stdin.read_nonblock(2)
when 2 then $stdin.read(2)
end
puts "diener erhielt <<#{erg}>>"
$stdout.flush
sleep 0.2
}
-----------------------------------------------------------------
It works fine:
-----------------------------------------------------------------
C:\Dokumente und Einstellungen\wolfgang\Desktop>ruby read_nonblock_test.rb
diener=#<File:0x2df89e4>
:diener erhielt <<a
:>>
:diener erhielt <<b
:>>
:diener erhielt <<c
:>>
:diener erhielt <<d
:>>
:diener erhielt <<e
:>>
:diener erhielt <<f
:>>
:diener erhielt <<g
:>>
:diener erhielt <<h
:>>
nil erhalten.
Fertig.
-----------------------------------------------------------------
When changing the switch to "case 1", the result is the following (the
listing is a little bit confusing, because the output of one process
appears after the system prompt).
-----------------------------------------------------------------
C:\Dokumente und Einstellungen\wolfgang\Desktop>ruby read_nonblock_test.rb
diener=#<File:0x2df89e4>
read_nonblock_test.rb:9:in `read_nonblock': Bad file descriptor
(Errno::EBADF)
from read_nonblock_test.rb:9
from read_nonblock_test.rb:20:in `each'
from read_nonblock_test.rb:4
C:\Dokumente und
Einstellungen\wolfgang\Desktop>read_nonblock_diener.rb:4:in
`read_nonblock': Bad fi
le descriptor (Errno::EBADF)
from read_nonblock_diener.rb:4
from read_nonblock_diener.rb:1:in `times'
from read_nonblock_diener.rb:1
-----------------------------------------------------------------
Now I started some first tests with Ruby 1.9 (Windows2000, MinGW/MSYS
generated) and received some other problems. In the moment we started
the discussion about them in German Ruby-Forum. I will report them here
if they are not based on errors I made.
Greets, WOlfgang N?dasi-Donner