To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example provides an reconnecting network stream class that can be used to create applications that communicate over the network.
Description
The Stream.lvclass implements an asynchronous daemon that handles the two way connection of a network stream. The daemon is spawned dynamically when you create a stream and you enqueue messages to the outgoing queue that the daemon needs to send over the network. The messages that are transmitted back are read by the daemon and enqueued locally in the incoming queue.
IP with context is required because network streams connect to endpoints in executables based on the executables context (the name of the executable).
This is covered here: Specifying Network Stream Endpoint URLs




Steps to Implement or Execute Code
1. Make sure that your VI Package manager is in version 14 or higher.
2. Install the package.
3. Find the Object Reconnecting Stream in Addons palette in LabVIEW.
4. Run the Example VI for Example palette.
5. Experiment with the code and connection manager.
Requirements
There is experimental 2011 version available but it was not tested. Use at your own risk.
Additional Images or Video
https://www.youtube.com/watch?v=3fn1T9z85ac&feature=youtu.be
Changes in Version 3.2.0.1
Changes in Version 3.1.0.7 (minor bug fix)
Changes in Version 3.1.0.6
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
I am using multiple parallel Streams (each in an Actor) and I noticed that when a Stream is disconnected, the cpu usage was high. Performance profiling pointed me to the Writer Loop.vi and Reader Loop.vi in Stream.lvclass.
There is a while loop with a case inside: the "Connected" case has a 50ms Wait until next ms multiple, while the disconnect case does not - which I suspect is the cause of high cpu usage.
Shouldn't the Wait until ms multiple be outside the case structure? Is this an oversight or a design decision?
EDIT: I just made a local fix by moving the Wait until ms multiple outside the case structure. The high cpu usage is fixed, but it feels like it takes longer to reconnect.