1io_tryread(3)              Library Functions Manual              io_tryread(3)
2
3
4

NAME

6       io_tryread - read from a descriptor without blocking
7

SYNTAX

9       #include <io.h>
10
11       int io_tryread(int64 fd,char* buf,int64 len);
12

DESCRIPTION

14       io_tryread  tries  to  read  len  bytes of data from descriptor fd into
15       buf[0], buf[1], ..., buf[len-1]. (The effects are undefined if len is 0
16       or smaller.) There are several possible results:
17
18
19       ·  o_tryread returns an integer between 1 and len: This number of bytes
20          was available for immediate reading; the bytes were  read  into  the
21          beginning  of  buf.  Note  that  this  number  can be, and often is,
22          smaller than len; you must not assume that  io_tryread  always  suc‐
23          ceeds in reading exactly len bytes.
24
25       ·  io_tryread  returns 0: No bytes were read, because the descriptor is
26          at end of file. For example, this descriptor has reached the end  of
27          a disk file, or is reading an empty pipe that has been closed by all
28          writers.
29
30       ·  io_tryread returns -1, setting errno to EAGAIN: No bytes were  read,
31          because  the descriptor is not ready. For example, the descriptor is
32          reading an empty pipe that could still be written to.
33
34       ·  io_tryread returns -3, setting errno to something other than EAGAIN:
35          No  bytes  were read, because the read attempt encountered a persis‐
36          tent error, such as a serious disk  failure  (EIO),  an  unreachable
37          network (ENETUNREACH), or an invalid descriptor number (EBADF).
38
39       io_tryread  does  not pause waiting for a descriptor that is not ready.
40       If you want to pause, use io_waitread or io_wait.
41
42       You can make io_tryread faster and more efficient by making the  socket
43       non-blocking with io_nonblock().
44

SEE ALSO

46       io_nonblock(3), io_waitread(3), io_tryreadtimeout(3)
47
48
49
50                                                                 io_tryread(3)
Impressum