PATH:
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
IO
U:RDoc::AnyMethod[iI"read_nonblock:ETI"IO#read_nonblock;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"?Reads at most <i>maxlen</i> bytes from <em>ios</em> using ;TI"9the read(2) system call after O_NONBLOCK is set for ;TI"$the underlying file descriptor.;To:RDoc::Markup::BlankLine o; ; [ I"8If the optional <i>outbuf</i> argument is present, ;TI">it must reference a String, which will receive the data. ;TI"QThe <i>outbuf</i> will contain only the received data after the method call ;TI".even if it is not empty at the beginning.;T@o; ; [I"7read_nonblock just calls the read(2) system call. ;TI"aIt causes all errors the read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc. ;TI"(The caller should care such errors.;T@o; ; [ I">If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, ;TI")it is extended by IO::WaitReadable. ;TI"KSo IO::WaitReadable can be used to rescue the exceptions for retrying ;TI"read_nonblock.;T@o; ; [I"*read_nonblock causes EOFError on EOF.;T@o; ; [I"LOn some platforms, such as Windows, non-blocking mode is not supported ;TI"Hon IO objects other than sockets. In such cases, Errno::EBADF will ;TI"be raised.;T@o; ; [I"+If the read byte buffer is not empty, ;TI";read_nonblock reads from the buffer like readpartial. ;TI"9In this case, the read(2) system call is not called.;T@o; ; [ I"FWhen read_nonblock raises an exception kind of IO::WaitReadable, ;TI"(read_nonblock should not be called ;TI"2until io is readable for avoiding busy loop. ;TI"!This can be done as follows.;T@o:RDoc::Markup::Verbatim; [I"-# emulates blocking read (readpartial). ;TI"begin ;TI") result = io.read_nonblock(maxlen) ;TI"rescue IO::WaitReadable ;TI" IO.select([io]) ;TI" retry ;TI" end ;T:@format0o; ; [ I"?Although IO#read_nonblock doesn't raise IO::WaitWritable. ;TI"BOpenSSL::Buffering#read_nonblock can raise IO::WaitWritable. ;TI"3If IO and SSL should be used polymorphically, ;TI"-IO::WaitWritable should be rescued too. ;TI"JSee the document of OpenSSL::Buffering#read_nonblock for sample code.;T@o; ; [I"7Note that this method is identical to readpartial ;TI")except the non-blocking flag is set.;T@o; ; [ I"OBy specifying a keyword argument _exception_ to +false+, you can indicate ;TI"Lthat read_nonblock should not raise an IO::WaitReadable exception, but ;TI"Lreturn the symbol +:wait_readable+ instead. At EOF, it will return nil ;TI"!instead of raising EOFError.;T: @fileI" io.rb;T:0@omit_headings_from_table_of_contents_below0I"ios.read_nonblock(maxlen [, options]) -> string ios.read_nonblock(maxlen, outbuf [, options]) -> outbuf ;T0[ I"&(len, buf = nil, exception: true);T@OFI"IO;TcRDoc::NormalClass00
[+]
..
[-] raw-i.ri
[edit]
[-] each_byte-i.ri
[edit]
[-] echo%3f-i.ri
[edit]
[-] nonblock-i.ri
[edit]
[-] scroll_forward-i.ri
[edit]
[-] copy_stream-c.ri
[edit]
[-] goto-i.ri
[edit]
[-] erase_line-i.ri
[edit]
[-] readchar-i.ri
[edit]
[+]
EINPROGRESSWaitReadable
[-] write-c.ri
[edit]
[-] getch-i.ri
[edit]
[-] isatty-i.ri
[edit]
[-] readlines-i.ri
[edit]
[-] ioctl-i.ri
[edit]
[-] sysseek-i.ri
[edit]
[-] try_convert-c.ri
[edit]
[+]
EINPROGRESSWaitWritable
[-] readlines-c.ri
[edit]
[-] oflush-i.ri
[edit]
[-] %3c%3c-i.ri
[edit]
[-] binwrite-c.ri
[edit]
[-] eof-i.ri
[edit]
[-] ungetc-i.ri
[edit]
[-] ttyname-i.ri
[edit]
[+]
generic_readable
[-] pwrite-i.ri
[edit]
[-] console_mode-i.ri
[edit]
[-] winsize-i.ri
[edit]
[-] nonblock%3d-i.ri
[edit]
[-] set_encoding_by_bom-i.ri
[edit]
[-] closed%3f-i.ri
[edit]
[-] wait_readable-i.ri
[edit]
[+]
Buffer
[-] sync%3d-i.ri
[edit]
[-] sysread-i.ri
[edit]
[-] each_line-i.ri
[edit]
[-] echo%3d-i.ri
[edit]
[-] raw%21-i.ri
[edit]
[-] cdesc-IO.ri
[edit]
[-] read_nonblock-i.ri
[edit]
[-] rewind-i.ri
[edit]
[-] binmode%3f-i.ri
[edit]
[-] close_on_exec%3f-i.ri
[edit]
[-] write_nonblock-i.ri
[edit]
[+]
generic_writable
[-] expect-i.ri
[edit]
[-] flush-i.ri
[edit]
[-] lineno-i.ri
[edit]
[-] stat-i.ri
[edit]
[-] new-c.ri
[edit]
[-] printf-i.ri
[edit]
[-] cursor_up-i.ri
[edit]
[-] autoclose%3f-i.ri
[edit]
[-] cooked%21-i.ri
[edit]
[-] wait-i.ri
[edit]
[-] getc-i.ri
[edit]
[-] clear_screen-i.ri
[edit]
[-] external_encoding-i.ri
[edit]
[-] readpartial-i.ri
[edit]
[-] seek-i.ri
[edit]
[-] close_read-i.ri
[edit]
[-] getpass-i.ri
[edit]
[-] nread-i.ri
[edit]
[-] tty%3f-i.ri
[edit]
[-] pipe-c.ri
[edit]
[-] read-c.ri
[edit]
[-] sync-i.ri
[edit]
[-] cooked-i.ri
[edit]
[-] erase_screen-i.ri
[edit]
[-] putc-i.ri
[edit]
[+]
ConsoleMode
[-] to_path-i.ri
[edit]
[-] set_encoding-i.ri
[edit]
[-] cursor%3d-i.ri
[edit]
[-] lineno%3d-i.ri
[edit]
[-] close-i.ri
[edit]
[-] select-c.ri
[edit]
[+]
EAGAINWaitWritable
[-] each-i.ri
[edit]
[-] fcntl-i.ri
[edit]
[-] pos-i.ri
[edit]
[-] open-c.ri
[edit]
[-] reopen-i.ri
[edit]
[+]
TimeoutError
[+]
EWOULDBLOCKWaitWritable
[-] readline-i.ri
[edit]
[-] pid-i.ri
[edit]
[-] cursor_right-i.ri
[edit]
[-] wait_writable-i.ri
[edit]
[-] path-i.ri
[edit]
[-] nonblock%3f-i.ri
[edit]
[-] readbyte-i.ri
[edit]
[-] binmode-i.ri
[edit]
[-] ioflush-i.ri
[edit]
[-] puts-i.ri
[edit]
[-] getbyte-i.ri
[edit]
[-] close_on_exec%3d-i.ri
[edit]
[-] each_char-i.ri
[edit]
[-] wait_priority-i.ri
[edit]
[-] goto_column-i.ri
[edit]
[-] to_i-i.ri
[edit]
[-] check_winsize_changed-i.ri
[edit]
[+]
WaitReadable
[-] fsync-i.ri
[edit]
[-] cursor_down-i.ri
[edit]
[-] pos%3d-i.ri
[edit]
[-] pread-i.ri
[edit]
[-] each_codepoint-i.ri
[edit]
[-] pressed%3f-i.ri
[edit]
[-] timeout%3d-i.ri
[edit]
[-] syswrite-i.ri
[edit]
[-] timeout-i.ri
[edit]
[-] gets-i.ri
[edit]
[-] cursor-i.ri
[edit]
[-] ungetbyte-i.ri
[edit]
[-] for_fd-c.ri
[edit]
[-] ready%3f-i.ri
[edit]
[-] winsize%3d-i.ri
[edit]
[-] internal_encoding-i.ri
[edit]
[-] fdatasync-i.ri
[edit]
[-] iflush-i.ri
[edit]
[-] popen-c.ri
[edit]
[-] binread-c.ri
[edit]
[-] read-i.ri
[edit]
[-] sysopen-c.ri
[edit]
[-] beep-i.ri
[edit]
[-] advise-i.ri
[edit]
[-] scroll_backward-i.ri
[edit]
[-] pathconf-i.ri
[edit]
[-] write-i.ri
[edit]
[-] console_mode%3d-i.ri
[edit]
[-] autoclose%3d-i.ri
[edit]
[-] inspect-i.ri
[edit]
[+]
WaitWritable
[-] close_write-i.ri
[edit]
[-] tell-i.ri
[edit]
[-] fileno-i.ri
[edit]
[-] cursor_left-i.ri
[edit]
[+]
EWOULDBLOCKWaitReadable
[-] print-i.ri
[edit]
[-] foreach-c.ri
[edit]
[-] eof%3f-i.ri
[edit]
[-] console-c.ri
[edit]
[-] to_io-i.ri
[edit]
[-] noecho-i.ri
[edit]
[+]
EAGAINWaitReadable