Home Contents | # rawio:writet | Rawio | Core4 Lua Event System

## SYNOPSIS

handle:writet(data, timeout)

## DESCRIPTION

Writes data to the open file. Even if the handle has been set to non-blocking mode, the write will wait until all data has been written or the timeout expires.

## RETURN VALUE

On success, returns the number of bytes written, on failure, returns nil. In case of an error, the error can be retrieved using rawio:lastError().

When the timeout has expired and some data could be written, the function returns the number of bytes that could be written. If no data could be written, it returns a failure with the error code ETIME.

## NOTES

Please note that Lua considers the number '0' true. Using

if (handle:write(...)) then print("OK") end
will happily print OK if zero bytes where written.

## SEE ALSO

rawio.attach, rawio:blocking, rawio:canReadLine, rawio:clearError, rawio:close, rawio:connect, rawio:detach, rawio:lastError, rawio:line, rawio:lines, rawio.access, rawio.open, rawio:read, rawio:slurp, rawio:copy, rawio.stat, rawio.statfs, rawio:writes, rawio:write