Table of Contents
stream_receive_doubles
Receives an array of 64-bit, double-position, floating-point numbers over a client stream.
Description
This function receives an array of 64-bit, double-position, floating-point numbers over a client stream. 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 each double-precision floating-point number that it receives before storing them in the given buffer.
Unlike the stream_receive_double_array function, this function does not require that the stream receive buffer be at least num_elements 64-bit floats in length. Hence, it allows smaller stream buffers to be used.
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 size of a double-precision floating-point number then it returns -QERR_WOULD_BLOCK. In this case, the stream_poll function may be used with the STREAM_POLL_RECEIVE flag to determine when data becomes available. Otherwise it returns the number of double-precision floating-point numbers received.
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 double-precision floating-point number. Otherwise it returns the number of double-precision floating-point numbers read before the connection closed. Once there are fewer bytes left to receive than the size of a double-precision floating-point number 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_doubles(t_stream stream, t_double * elements, t_uint num_elements);
Parameters
t_stream stream
A client stream established using stream_connect or stream_accept.
t_double * elements
A pointer to an array of t_double variables in which the received data will be stored. It must be at least num_elements in length.
t_uint num_elements
The number of elements to receive.
Return value
The number of double-precision floating-point numbers received, which may be less than the requested number for non-blocking streams. If fewer bytes than size of a double-precision floating-point number 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
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.