U:RDoc::AnyMethod[iI"write_nonblock:EFI"IO#write_nonblock;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"3Writes the given string to ios using ;TI":the write(2) system call after O_NONBLOCK is set for ;TI"$the underlying file descriptor.;To:RDoc::Markup::BlankLine o;
; [I",It returns the number of bytes written.;T@o;
; [ I"9write_nonblock just calls the write(2) system call. ;TI"bIt causes all errors the write(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc. ;TI"HThe result may also be smaller than string.length (partial write). ;TI":The caller should care such errors and partial write.;T@o;
; [I">If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, ;TI")it is extended by IO::WaitWritable. ;TI"ZSo IO::WaitWritable can be used to rescue the exceptions for retrying write_nonblock.;T@o:RDoc::Markup::Verbatim; [I"# Creates a pipe.
;TI"r, w = IO.pipe
;TI"
;TI"@# write_nonblock writes only 65536 bytes and return 65536.
;TI";# (The pipe size is 65536 bytes on this environment.)
;TI"s = "a" * 100000
;TI")p w.write_nonblock(s) #=> 65536
;TI"
;TI"J# write_nonblock cannot write a byte and raise EWOULDBLOCK (EAGAIN).
;TI"Rp w.write_nonblock("b") # Resource temporarily unavailable (Errno::EAGAIN)
;T:@format0o;
; [I">If the write buffer is not empty, it is flushed at first.;T@o;
; [ I"GWhen write_nonblock raises an exception kind of IO::WaitWritable, ;TI")write_nonblock should not be called ;TI"2until io is writable for avoiding busy loop. ;TI"!This can be done as follows.;T@o;; [I"begin
;TI"* result = io.write_nonblock(string)
;TI"+rescue IO::WaitWritable, Errno::EINTR
;TI" IO.select(nil, [io])
;TI"
retry
;TI" end
;T;
0o;
; [I"CNote that this doesn't guarantee to write all data in string. ;TI"MThe length written is reported as result and it should be checked later.;T@o;
; [I"HOn some platforms such as Windows, write_nonblock is not supported ;TI"-according to the kind of the IO object. ;TI"DIn such cases, write_nonblock raises Errno::EBADF
.;T@o;
; [I"OBy specifying a keyword argument _exception_ to +false+, you can indicate ;TI"Mthat write_nonblock should not raise an IO::WaitWritable exception, but ;TI"0return the symbol +:wait_writable+ instead.;T:
@fileI"prelude.rb;T:0@omit_headings_from_table_of_contents_below0I"aios.write_nonblock(string) -> integer
ios.write_nonblock(string [, options]) -> integer
;T0[ I"(buf, exception: true);T@JFI"IO;TcRDoc::NormalClass00