### Method

# Gio PollableOutputStream write_nonblocking

#### Declaration [src]

    gssize
    g_pollable_output_stream_write_nonblocking (
      GPollableOutputStream* stream,
      void* buffer,
      gsize count,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

Attempts to write up to `count` bytes from `buffer` to `stream`, as with g_output_stream_write(). If `stream` is not currently writable, this will immediately return `G_IO_ERROR_WOULD_BLOCK`, and you can use `g_pollable_output_stream_create_source()` to create a `GSource` that will be triggered when `stream` 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 `count` in the next write call.

The behaviour of this method is undefined if `g_pollable_output_stream_can_poll()` returns `FALSE` for `stream`.

#### Parameters

`buffer`

  Type: An array of `guint8`

  A buffer to write data from.

  The length of the array is specified in the `count` argument.
  The data is owned by the caller of the method.

`count`

  Type: `gsize`

  The number of bytes you want to write.

`cancellable`

  Type: `GCancellable`

  A `GCancellable`, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gssize`

The number of bytes written, or -1 on error (including `G_IO_ERROR_WOULD_BLOCK`).