write_nonblocking


Description:

public abstract ssize_t write_nonblocking (uint8[]? buffer) throws Error

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

If this is not currently writable, 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 writable.

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.

Also note that if g_io_error_would_block is returned some underlying transports like D/TLS require that you re-send the same buffer and buffer.length in the next write call.

Parameters:

this

a PollableOutputStream

buffer

a buffer to write data from

cancellable

a Cancellable, or null

count

the number of bytes you want to write

Returns:

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