stream_receive_utf32_chars stream_receive_short navigation bar

Table of Contents

stream_receive_utf32_char_array

Receives an array of UTF-32 characters over a client stream.

Description

This function receives an array of UTF-32 characters over a client stream. It returns exactly the number of code units requested. The return value is 1 if the entire array is received. It returns a negative error code if an error occurs. If the peer closes the stream gracefully then zero is returned.

If an illegal UTF-8 character is encountered then -QERR_ILLEGAL_UTF8_CHARACTER is returned.

If an illegal UTF-16 character is encountered then -QERR_ILLEGAL_UTF16_CHARACTER is returned.

If an illegal UTF-32 character is encountered then -QERR_ILLEGAL_UTF32_CHARACTER is returned.

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 that it receives before storing them in the given buffer.

If stream_listen or stream_connect was called with the non-blocking flag set to false (0), then this function blocks until all the data is read.

If stream_listen or stream_connect was called with the non-blocking flag set to true (1), then this function does not block. If fewer bytes are available then the number of code units specified then it returns -QERR_WOULD_BLOCK. In this case, the stream_poll available. Otherwise it returns the number of code units returned in the caller's buffer. This number may be smaller than the number requested even if all the requested bytes are available because this function never reads a partial character. Thus, there may be 1-3 bytes unused at the end of the buffer if the next character would occupy more than the bytes available.

If the connection has been closed gracefully then it returns 0 only if there are fewer bytes left to receive than the size of a character. Otherwise it returns the number of characters read before the connection closed. Once there are fewer bytes left to receive than the size of a character then it will return 0 to indicate the connection has been closed. Use stream_receive to receive any remaining bytes if required. If an error occurs, then it returns a negative error code.

This function does not support two threads receiving data at the same time. However, data may be sent 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_receive_utf32_char_array(t_stream stream, t_utf32_char * buffer, t_int max_code_units);

    

Parameters

t_stream stream

A client stream established using stream_connect or stream_accept.

t_utf32_char * buffer

A pointer to an array of t_utf32_char's in which the received characters will be stored.

t_int max_code_units

The size of the buffer in code units (32-bit words).

Return value

Returns 1 upon success. If fewer code units than the size of the array are available and the connection has been closed gracefully then 0 is returned. 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

 

navigation bar