Home  Contents

rawio:read

Rawio Core4 Lua Event System

SYNOPSIS

handle:read([maxlen [, timeout]])

DESCRIPTION

Reads at most maxlen bytes of data from the open file. The default for maxlen is 4096 bytes.

In non blocking mode, returns immediately if less data is available than requested, returning the data that could be read so far. In blocking mode, the call will wait for data to become available before it returns.

If the optional timeout value is given, the call will wait for this amount of milliseconds for data before it fails. This applies to both blocking and non-blocking mode.

RETURN VALUE

On success, returns a string with the data that was read. On failure or end-of-file, returns nil. In case of an error, the error can be retrieved using rawio:lastError().

NOTES

Also returns nil on end-of-file. Calling rawio:lastError() will return nil, too, in that case, indicating no error.

SEE ALSO