Method

GioPollableOutputStreamwritev_nonblocking

Declaration

GPollableReturn
g_pollable_output_stream_writev_nonblocking (
  GPollableOutputStream* stream,
  const GOutputVector* vectors,
  gsize n_vectors,
  gsize* bytes_written,
  GCancellable* cancellable,
  GError** error
)

Description

Attempts to write the bytes contained in the n_vectors vectors to stream, as with g_output_stream_writev(). If stream is not currently writable, this will immediately return %G_POLLABLE_RETURN_WOULD_BLOCK, and you can use g_pollable_output_stream_create_source() to create a GSource that will be triggered when stream is writable. error will not be set in that case.

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_POLLABLE_RETURN_WOULD_BLOCK is returned some underlying transports like D/TLS require that you re-send the same vectors and n_vectors in the next write call.

Available since:2.60

Parameters

vectors An array of GOutputVector
 

The buffer containing the GOutputVectors to write.

 The length of the array is specified in the n_vectors argument.
 The data is owned by the caller of the function.
n_vectors gsize
 

The number of vectors to write.

bytes_written gsize*
 

Location to store the number of bytes that were written to the stream.

 The argument will be set by the function.
 The argument can be NULL.
cancellable GCancellable
 

A GCancellable, or NULL.

 The argument can be NULL.
 The data is owned by the caller of the function.
error GError **
  The return location for a GError*, or NULL.

Return value

Returns: GPollableReturn
 

%G_POLLABLE_RETURN_OK on success, G_POLLABLE_RETURN_WOULD_BLOCK if the stream is not currently writable (and error is not set), or G_POLLABLE_RETURN_FAILED if there was an error in which case error will be set.