read_nonblocking


Description:

public ssize_t read_nonblocking (uint8[] buffer, Cancellable? cancellable = null) throws Error

Attempts to read up to buffer.length bytes from this into buffer, as with read.

If this is not currently readable, this will immediately return g_io_error_would_block, and you can use create_source to create a SocketSource that will be triggered when this is readable.

Note that since this method never blocks, you cannot actually use cancellable to cancel it. However, it will return an error if cancellable has already been cancelled when you call, which may happen if you call this method after a source triggers due to having been cancelled.

Parameters:

this

a PollableInputStream

buffer

a buffer to read data into (which should be at least buffer.length bytes long).

cancellable

a Cancellable, or null

count

the number of bytes you want to read

Returns:

the number of bytes read, or -1 on error (including g_io_error_would_block).