U:RDoc::AnyMethod[iI"readpartial:ETI"IO#readpartial;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"maxlen bytes from the I/O stream. ;TI"GIt blocks only if ios has no data immediately available. ;TI"-It doesn't block if some data available.;To:RDoc::Markup::BlankLineo; ; [ I"3If the optional _outbuf_ argument is present, ;TI">it must reference a String, which will receive the data. ;TI"LThe _outbuf_ will contain only the received data after the method call ;TI".even if it is not empty at the beginning.;T@o; ; [I"4It raises EOFError on end of file.;T@o; ; [I"Ireadpartial is designed for streams such as pipe, socket, tty, etc. ;TI"8It blocks only when no data immediately available. ;TI"GThis means that it blocks only when following all conditions hold.;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"/the byte buffer in the IO object is empty.;To;;0; [o; ; [I"(the content of the stream is empty.;To;;0; [o; ; [I"&the stream is not reached to EOF.;T@o; ; [I"BWhen readpartial blocks, it waits data or EOF on the stream. ;TI"AIf some data is reached, readpartial returns with the data. ;TI"4If EOF is reached, readpartial raises EOFError.;T@o; ; [ I"HWhen readpartial doesn't blocks, it returns or raises immediately. ;TI"IIf the byte buffer is not empty, it returns the data in the buffer. ;TI"/Otherwise if the stream has some content, ;TI"(it returns the data in the stream. ;TI"COtherwise if the stream is reached to EOF, it raises EOFError.;T@o:RDoc::Markup::Verbatim; [I"Kr, w = IO.pipe # buffer pipe content ;TI"Ew << "abc" # "" "abc". ;TI"Ar.readpartial(4096) #=> "abc" "" "" ;TI"Ir.readpartial(4096) # blocks because buffer and pipe is empty. ;TI" ;TI"Kr, w = IO.pipe # buffer pipe content ;TI"Dw << "abc" # "" "abc" ;TI"Hw.close # "" "abc" EOF ;TI"Br.readpartial(4096) #=> "abc" "" EOF ;TI"0r.readpartial(4096) # raises EOFError ;TI" ;TI"Kr, w = IO.pipe # buffer pipe content ;TI"Kw << "abc\ndef\n" # "" "abc\ndef\n" ;TI"Ar.gets #=> "abc\n" "def\n" "" ;TI"Fw << "ghi\n" # "def\n" "ghi\n" ;TI"Fr.readpartial(4096) #=> "def\n" "" "ghi\n" ;TI"Ar.readpartial(4096) #=> "ghi\n" "" "" ;T: @format0o; ; [I"7Note that readpartial behaves similar to sysread. ;TI"The differences are:;To; ; ;;[o;;0; [o; ; [I"oIf the byte buffer is not empty, read from the byte buffer instead of "sysread for buffered IO (IOError)".;To;;0; [o; ; [I"›It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial meets EWOULDBLOCK and EINTR by read system call, readpartial retry the system call.;T@o; ; [I"HThe latter means that readpartial is nonblocking-flag insensitive. ;TI"cIt blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode.;T: @fileI" io.c;T:0@omit_headings_from_table_of_contents_below0I"cios.readpartial(maxlen) -> string ios.readpartial(maxlen, outbuf) -> outbuf ;T0[I" (*args);T@cFI"IO;TcRDoc::NormalClass00