stream_connect stream_accept navigation bar

Table of Contents

stream_listen

Creates a listening stream.

Syntax

stream = stream_listen(uri, nonblocking)
stream = stream_listen(uri)                 % blocking listening stream
    

Description

Creates a listening stream. The communication protocol, hostname, port and options are specified via the first argument, which takes the form of a Universal Resource Identifier (URI). For example, 'tcpip://localhost:18000' indicates that the stream should use the TCP/IP protocol and listen on port 18000. Likewise, 'shmem://mymemory:1' indicates that the stream should use the shared memory protocol and listen to shared memory 'mymemory' and port 1. Refer to the help on Universal Resource Identifiers or the Stream Listen block for Simulink for more information.

Streams are normally blocking. Specify nonblocking as true to create a non-blocking listening stream. Specify nonblocking as false to create a blocking listening stream. A blocking listening stream does not return from a stream_accept call until a connection from a client has been accepted. A non-blocking listening stream does not block in stream_accept but always return immediately. See stream_accept for details.

When finished with the stream, the stream must be closed with stream_close or stream_close_all.

Parameters

uri

A string containing the URI. eg. 'tcpip://quanser-dev:18000' or 'shmem://comm_server:1'.

nonblocking

A boolean indicating whether the stream is nonblocking (true or 1) or blocking (false or 0).

Outputs

stream

A handle to the listening stream for use with the other Quanser Stream functions.

Examples

stream = stream_listen('tcpip://localhost:18000');    % Listen on TCP/IP port 18000
...
stream_close(stream);                                 % Close the stream to release resources
    

See Also

 

navigation bar