黒田です。 >青山です。 > >TCPsocket.open のタイムアウト処理には何か有効な方法があるでしょうか? 確か原版は石塚さんだったと思いますが、 - -- class TimeOut < Exception end def timeout(sec) is_timeout = FALSE begin x = Thread.current y = Thread.start { sleep sec if x.alive? #print "timeout!\n" x.raise TimeOut, "timeout" end } begin yield rescue TimeOut is_timeout = TRUE end ensure Thread.kill y if y && y.alive? end is_timeout end is_timeout = timeout(10){ http = TCPsocket.open(host, port) .... } .... - -- という使い方をしています。 #あぁ、まだ公開してないや、proxy韓庫君。 - -- 黒田 淳 (くろだ じゅん)