Table of Contents
stream_poke_utf8_char_array
Writes an array of UTF-8 characters to the stream buffer.
Description
This function writes an array of UTF-8 characters to the stream buffer. The characters are converted according to the stream's character format prior to writing the characters to the stream buffer. It attempts to store the converted characters in the stream buffer. It either writes all of the array or none of it. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. However, the stream pointer is not advanced, so the data is not written to the actual communication channel. The data will only allowed to be written to the underlying communication channel if stream_poke_end is called. If an error occurs, then it returns a negative error code. If the connection is closed it is considered an error condition.
The size of the stream send buffer must be at least as large as the number of code units being sent.
Note that this function only writes complete characters to the stream. It will not write some but not all of the code units comprising a multi-unit character.
If the stream has been configured to swap bytes using stream_set_swap_bytes or stream_set_byte_order then this function will swap the order of the bytes within the converted character if the stream's character format is UTF-16 or UTF-32.
If stream_listen or stream_connect was called with the non-blocking flag set to false (0), then this function may block attempting to flush the stream buffer (to write out data previously sent and still waiting in the stream buffer). Once the entire array is poked into the buffer then 1 is returned. If an error occurs then the error code is returned and the stream should be closed.
If stream_listen or stream_connect was called with the non-blocking flag set to true (1), then this function does not block. It returns 1 on success. If the entire array could not be poked without blocking, then -QERR_WOULD_BLOCK is returned. If an error occurs then the error code is returned and the stream should be closed.
This function does not support two threads poking or flushing data at the same time. However, data may be poked or the stream flushed by another thread at the same time as data is being received.
The BSD socket API has no equivalent to this function.
Prototype
t_int stream_poke_utf8_char_array(t_stream stream, t_stream_poke_state * state, const t_utf8_char * buffer, t_int code_units);
Parameters
t_stream stream
A client stream established using stream_connect or stream_accept.
t_stream_poke_state * state
The poke state initialized using stream_poke_begin.
const t_utf8_char * buffer
A pointer to an array of t_utf8_char's containing the characters to send. A UTF-8 character may take up to 4 code units or bytes.
t_int code_units
The size of the buffer in code units (bytes).
Return value
Returns 1 on success. If an error occurs then a negative error code is returned.
Error codes
This function does not return any error code.
Requirements
Include Files |
Libraries |
---|---|
quanser_stream.h |
quanser_communications.lib;quanser_runtime.lib;quanser_common.lib |
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.