Method Stdio.Fd()->read_oob()
- Method read_oob
stringread_oob()
stringread_oob(intlen)
stringread_oob(intlen,boolnot_all)- Description
Attempts to read
lenbytes of out-of-band data from the stream, and returns it as a string. Less thanlenbytes can be returned if:the stream has been closed from the other end, or
nonblocking mode is used, or
not_allis set, ornot_allisn't set and an error occurred (see below).
If
not_allis nonzero, read_oob() only returns as many bytes of out-of-band data as are currently available.If something goes wrong and
not_allis set, zero is returned. If something goes wrong andnot_allis zero or left out, then either zero or a string shorter thanlenis returned. If the problem persists then a later call to read_oob() fails and returns zero, however.If everything went fine, a call to errno() directly afterwards returns zero. That includes an end due to remote close.
If no arguments are given, read_oob() reads to the end of the stream.
- Note
It is not guaranteed that all out-of-band data sent from the other end is received. Most streams only allow for a single byte of out-of-band data at a time.
- Note
It's not necessary to set
not_allto avoid blocking reading when nonblocking mode is used.- Note
When at the end of a file or stream, repeated calls to read() returns the empty string since it's not considered an error. The empty string is never returned in other cases, unless nonblocking mode is used or
lenis zero.- See also