Method Stdio.Fd()->peek()
- Method peek
int(-1..1)peek()
int(-1..1)peek(int|floattimeout)
int(-1..1)peek(int|floattimeout,intnot_eof)- Description
Check if there is data available to read, or wait some time for available data to read.
More specifically, a later call to read() will return immediately, either due to data being present, or due to some error (eg if a socket has been closed).
- Parameter
timeout Timeout in seconds.
- Parameter
not_eof Flag for specifying handling of end of file. The following values are currently defined:
0Traditional (and default) behaviour. Return
1at EOF.1Regard EOF as an error. Return
-1and set errno() to returnEPIPEat EOF.- Returns
1There is data available to read(), or
not_eofis0(zero) and we're at EOF. A later call to read() will not block.0There is no data available (ie timeout).
-1Error condition. The error code returned by errno() has been updated.
- See also
- Note
The function may be interrupted prematurely of the timeout (due to signals); check the timing manually if this is imporant.