stream_receive_uint64_array stream_receive_singles navigation bar

Table of Contents

stream_receive_single

Receives a 32-bit floating-point number from a stream.

Syntax

[data, would_block] = stream_receive_single(stream)
    

Description

This function receives a single 32-bit real number over a client stream.

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 the connection has been closed gracefully then it returns an empty array only once there is no more data to receive. Otherwise it returns the 32-bit real number read before the connection closed. Once all the data in the stream buffer is exhausted it will return an empty array to indicate the connection has been closed. If an error occurs, then it issues an error message.

If stream_listen or stream_connect was called with the non-blocking flag set to true (1), then this function does not block. If no data is available at all then it returns would_block equal to true. In this case, the stream_poll function may be used with the 'receive' flag to determine when data becomes available. Otherwise it returns the 32-bit real number received.

This operation is not valid on listening streams created using stream_listen.

Parameters

stream

Stream handle returned by stream_connect or stream_accept.

Outputs

data

The 32-bit real number received, as a single. For blocking streams, if this array is empty then the connection has been closed gracefully. For non-blocking streams, would_block must also be false to indicate closure.

would_block

Whether the function would have blocked. Always false for blocking streams.

Examples

data = stream_receive_single(stream);    % Receive one 32-bit real number
    

See Also

 

navigation bar