stream_send_unit_array stream_print_utf8_charsV navigation bar

Table of Contents

stream_flush

Flushes the stream buffer.

Description

This function flushes the stream buffer. It attempts to send the contents of the buffer over the communication channel. If an error occurs, then it returns a negative error code. 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 blocks until all the data in the buffer is sent.

If stream_listen or stream_connect was called with the non-blocking flag set to true (1), then this function does not block. It attempts to send all the data remaining in the stream buffer. However, if this operation would block then it returns -QERR_WOULD_BLOCK, even if it has already sent some of the data. In this case, the stream_poll function may be used with the STREAM_POLL_FLUSH flag to determine when at least one more byte may be flushed.

This function does not support two threads calling stream_send or stream_flush at the same time. However, stream_send or stream_flush may be called by another thread at the same time as stream_receive.

Prototype

t_error
stream_flush(t_stream stream);
    

Parameters

t_stream stream

A client stream established using stream_connect or stream_accept.

Return value

Returns 0 if the buffer is flushed. 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

Examples

const char uri[] = "shmem://foobar:1";
const t_boolean nonblocking = false;
const t_int send_buffer_size = 8000;
const t_int receive_buffer_size = 8000;

t_stream client;       
        
result = stream_connect(uri, nonblocking, send_buffer_size, receive_buffer_size, &client);
if (result == 0){
    ...
    while (!stop){
        ...
        result = stream_flush(client);
        if (result < 0)
        break;
        ...
    }
}
    

See Also

 

navigation bar