nabto_device_stream_write()

DESCRIPTION

Write bytes to a stream.

When the future resolves the data is only written to the stream, but not neccessary acked. This is why it does not make sense to return a number of actual bytes written in case of error since it says nothing about the number of acked bytes. To ensure that written bytes have been acked, a succesful call to nabto_device_stream_close() is neccessary after last call to nabto_device_stream_write().

Future status:

  • NABTO_DEVICE_EC_OK if write was ok.
  • NABTO_DEVICE_EC_CLOSED if the stream is closed for writing.
  • NABTO_DEVICE_EC_ABORTED if the stream is aborted.
  • NABTO_DEVICE_EC_OPERATION_IN_PROGRESS if stream is already being written to

DECLARATION

NABTO_DEVICE_DECL_PREFIX void NABTO_DEVICE_API
nabto_device_stream_write(NabtoDeviceStream* stream,
                          NabtoDeviceFuture* future,
                          const void* buffer,
                          size_t bufferLength)

PARAMETERS

stream:
[in] The stream to write data to.
future:
[in] Future to resolve with the result of the operation.
buffer:
[in] The input buffer with data to write to the stream.
bufferLength:
[in] Length of the input data.