PollableInputStreamT.readNonblocking

Attempts to read up to count bytes from stream into buffer, as with gio.input_stream.InputStream.read. If stream is not currently readable, this will immediately return gio.types.IOErrorEnum.WouldBlock, and you can use gio.pollable_input_stream.PollableInputStream.createSource to create a #GSource that will be triggered when stream 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.

The behaviour of this method is undefined if gio.pollable_input_stream.PollableInputStream.canPoll returns false for stream.

template PollableInputStreamT()
override
ptrdiff_t
readNonblocking

Parameters

buffer ubyte[]

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

cancellable gio.cancellable.Cancellable

a #GCancellable, or null

Return Value

Type: ptrdiff_t

the number of bytes read, or -1 on error (including gio.types.IOErrorEnum.WouldBlock).