Table of Contents
stream_send_int16
Sends a 16-bit integer over a stream.
[items_sent, would_block] = stream_send_int16(stream, value)
This function writes a single 16-bit integer to the stream buffer. It attempts to store the 16-bit integer value in the stream buffer. If there is enough room available in the stream buffer then it stores the data in the buffer and returns immediately. The data is not written to the actual communication channel until the stream is flushed using stream_flush or there is no more room available in the stream buffer. If an error occurs, then it issues an error message. If the connection is closed it is considered an error condition.
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. All the data will be consumed and the total number of elements sent is returned. Some of the data may remain in the stream buffer and not be sent until the next time stream_flush is called or there is no more room available in the stream buffer. If an error occurs then an error is issued 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 the number of elements sent successfully, which will be 1. If no elements could be sent without blocking, then would_block is set to true (1). If an error occurs then an error is issued and the stream should be closed.
This operation is not valid on listening streams created using stream_listen.
stream
Stream handle returned by stream_connect or stream_accept.
value
The 16-bit integer to send. Any numeric datatype may be used but the value will be cast to an int16 prior to writing the data to the stream.
items_sent
The number of items actually written to the stream buffer, which may be 0 for non-blocking streams. For blocking streams, a value of 0 is never returned.
would_block
Whether the function would have blocked. Always false for blocking streams.
num_items = stream_send_int16(stream, 120); % Send the 16-bit integer value 120
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.