Method Stdio.Fd()->peek()
- Method peek
int(-1..1)
peek()
int(-1..1)
peek(int
|float
timeout
)
int(-1..1)
peek(int
|float
timeout
,int
not_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:
0
Traditional (and default) behaviour. Return
1
at EOF.1
Regard EOF as an error. Return
-1
and set errno() to returnEPIPE
at EOF.- Returns
1
There is data available to read(), or
not_eof
is0
(zero) and we're at EOF. A later call to read() will not block.0
There is no data available (ie timeout).
-1
Error 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.
- Note
The
not_eof
parameter was added in Pike 7.7.- Note
This function was not available on NT in Pike 7.6 and earlier.