open file for reading as non block

J

Junkone

how do i open the file for reading as non blocking mode. as you can
see the first 2 attempts do not work.

irb(main):058:0> File.open(fi,File::NONBLOCK + File::RDONLY){|f|
c=f.read}
IOError: not opened for reading
from (irb):58:in `read'
from (irb):58
from (irb):58:in `open'
from (irb):58
from ¢¾:0
irb(main):059:0> File.open(fi,File::NONBLOCK ){|f| c=f.read}
IOError: not opened for reading
from (irb):59:in `read'
from (irb):59
from (irb):59:in `open'
from (irb):59
from ¢¾:0
irb(main):060:0> File.open(fi,"r" ){|f| c=f.read}
=> "test"
irb(main):061:0>
 
R

Robert Klemme

MjAwOC8xMC81IEp1bmtvbmUgPGp1bmtvbmUxQGdtYWlsLmNvbT46Cj4gaG93IGRvIGkgb3BlbiB0
aGUgZmlsZSBmb3IgcmVhZGluZyBhcyBub24gYmxvY2tpbmcgbW9kZS4gYXMgeW91IGNhbgo+IHNl
ZSB0aGUgZmlyc3QgMiBhdHRlbXB0cyBkbyBub3Qgd29yay4KPgo+IGlyYihtYWluKTowNTg6MD4g
RmlsZS5vcGVuKGZpLEZpbGU6Ok5PTkJMT0NLICsgRmlsZTo6UkRPTkxZKXt8ZnwKPiBjPWYucmVh
ZH0KPiBJT0Vycm9yOiBub3Qgb3BlbmVkIGZvciByZWFkaW5nCj4gICAgICAgIGZyb20gKGlyYik6
NTg6aW4gYHJlYWQnCj4gICAgICAgIGZyb20gKGlyYik6NTgKPiAgICAgICAgZnJvbSAoaXJiKTo1
ODppbiBgb3BlbicKPiAgICAgICAgZnJvbSAoaXJiKTo1OAo+ICAgICAgICBmcm9tIKK+OjAKCldv
cmtzIGZvciBtZToKCmlyYihtYWluKTowMDY6MD4gRmlsZS5vcGVuKCJlbnZpcm9ubWVudCIsIEZp
bGU6OlJET05MWSB8CkZpbGU6Ok5PTkJMT0NLKSB7fGlvfCBpby5yZWFkfS5zaXplCj0+IDQzOTgK
CklNSE8gInwiIGlzIGJldHRlciB0aGFuICIrIiBiZWNhdXNlIGl0IGV4cHJlc3NlcyBtb3JlIGNs
ZWFybHkgdGhhdAp0aGlzIGlzIGFib3V0IGJpdCBtYXNrcy4KCkJ0dywgd2hhdCBkbyB5b3UgZXhw
ZWN0IGZyb20gb3BlbmluZyBhIGZpbGUgbm9uYmxvY2tpbmc/ICBJcyB0aGVyZSBhbnkKb3RoZXIg
cHJvY2VzcyB3cml0aW5nIHRvIGl0PwoKQ2hlZXJzCgpyb2JlcnQKCi0tIApyZW1lbWJlci5ndXkg
ZG8gfGFzLCBvZnRlbnwgYXMueW91X2NhbiAtIHdpdGhvdXQgZW5kCg==
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top