when my problem is using multithreading to get some documents from www
server through net::http library. The code is as follows


Net::HTTP.start(url.host) do |http|
req = Net::HTTP::Get.new(url.path, {"User-Agent" =>
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; InfoPath.1)"})
response = http.request(req)
http.finish()
case response
when Net::HTTPSuccess
then return response.body
else
puts "Response Not Success"
return ""
end
end

I always receive errors as follows:

C:/ruby/lib/ruby/1.8/net/protocol.rb:133:in `sysread': end of file
reached (EOFE
rror)
        from C:/ruby/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
        from C:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
        from C:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
        from C:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
        from C:/ruby/lib/ruby/1.8/net/protocol.rb:86:in `read'
        from C:/ruby/lib/ruby/1.8/net/http.rb:2229:in `read_chunked'
        from C:/ruby/lib/ruby/1.8/net/http.rb:2204:in `read_body_0'
        from C:/ruby/lib/ruby/1.8/net/http.rb:2170:in `read_body'

And....

c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize': Bad file
descriptor - connect(2) (Errno::EBADF)
        from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `open'
        from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
        from c:/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout'
        from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
        from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `connect'
        from c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
        from c:/ruby/lib/ruby/1.8/net/http.rb:542:in `start'

-- 
Posted via http://www.ruby-forum.com/.