# \`sysread' end of file reached \`rbuf\_fill' problem

**URL:** <https://www.ruby-forum.com/t/sysread-end-of-file-reached-rbuf-fill-problem/78998>\
**Category:** Ruby\
**Created:** [December 11, 2006, 11:21am UTC](https://www.ruby-forum.com/t/sysread-end-of-file-reached-rbuf-fill-problem/78998 "2006-12-11T11:21:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mento\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@mento\_ruby](https://www.ruby-forum.com/u/mento_ruby)\
**Post date:** [December 11, 2006, 11:21am UTC](https://www.ruby-forum.com/t/sysread-end-of-file-reached-rbuf-fill-problem/78998/1 "2006-12-11T11:21:07Z")

</div>

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’
