Read data from a file or a stream.
Attempts to read len bytes from the file, and return it as a
string. Less than len bytes can be returned if:
end-of-file is encountered for a normal file, or
it's a stream that has been closed from the other end, or
it's a stream in nonblocking mode, or
it's a stream and not_all is set, or
not_all isn't set and an error occurred (see below).
If not_all is nonzero, read() will not try its best to read
as many bytes as you have asked for, but will merely return as
much as the system read function will return. This mainly useful
with stream devices which can return exactly one row or packet at
a time. If not_all is used in blocking mode, read() will
only block if there's no data at all available.
If something goes wrong and not_all is set, zero will be
returned. If something goes wrong and not_all is zero or left
out, then either zero or a string shorter than len is returned.
If the problem persists then a later call to read() will fail
and return zero, however.
If everything went fine, a call to errno() directly afterwards
will return zero. That includes an end due to end-of-file or
remote close.
If no arguments are given, read() will read to the
end of the file or stream.