From: John Feezell Date: 2004-07-22T22:10:59+09:00 Subject: Re: sysread and buffered I/O On Thu, 22 Jul 2004 16:01:06 +0900, Tanaka Akira wrote: > In article , > "John Feezell" writes: > >> Here are some other possible names that seems to fit with readchar, >> readline, >> and readlines and yet catch the idea of "readpartial." >> >> readportion >> readparcel >> readbundle >> readatmost >> >> Personally, "readatmost" would fit closes in my mind to the above >> description. > > "at most" doesn't represent the difference between IO#readpartial and > IO#read. IO#read also reads at most integer bytes from the I/O > stream. > > The difference is the blocking behaviour. > > % (sleep 1; echo abc; sleep 1; echo def) | ./ruby -e 't1 = Time.now; p > STDIN.readpartial(4096); t2 = Time.now; p t2-t1' > "abc\n" > 1.001541 > % (sleep 1; echo abc; sleep 1; echo def) | ./ruby -e 't1 = Time.now; p > STDIN.read(4096); t2 = Time.now; p t2-t1' > "abc\ndef\n" > 2.011527 > > Both IO#readpartial and IO#read blocks until some data are available. > But after some data are avalable, IO#readpartial just return the data > and doesn't block anymore. IO#read blocks until EOF or specified > length, though. Thanks. That makes the difference clearer. Well then, how about, readforedata #suggest that only the "first" or "some" data is read readandhalt #suggest reading is only partial