The following sections show examples of using the Network Streams functions to stream data continuously between applications and Network Stream Endpoint properties to view information about network stream endpoints.
Streaming Data with Network Streams Functions
The following figure shows an example of using the Network Streams functions to transfer data between two applications on different computers.
The following events occur in the previous figure.
- The Create Network Stream Writer Endpoint function creates a writer endpoint on Computer 1, and the Create Network Stream Reader Endpoint function creates a reader endpoint on Computer 2.
||Note You can run the Create Network Stream Writer Endpoint and Create Network Stream Reader Endpoint functions in any order. These functions will create a network stream unless the timeout in ms terminal on one function expires before the other function runs.
- The writer endpoint establishes a connection with the reader endpoint using the endpoint URL of the reader endpoint.
- The Write Single Element to Stream function continuously writes the value of the iteration (i) terminal of the While Loop to the stream.
||Note You also can use the Write Multiple Elements to Stream function to stream more than one data point at a time. For example, use this function if you need to stream two samples of waveform data every second.
- The Read Single Element from Stream function continuously reads the stream.
||Note You also can use the Read Multiple Elements from Stream function to read a stream. You can use a Read Multiple Elements from Stream function even if you used a Write Single Element to Stream function in the other application, and vice versa.
- Data streams continuously until the user clicks the stop button on Computer 1.
- The Flush Stream function transfers all remaining data to the reader endpoint.
- The Destroy Stream Endpoint function destroys the writer endpoint.
- The reader endpoint receives an error due to disconnection, and data flow exits the While Loop.
- The Destroy Stream Endpoint function destroys the reader endpoint, which destroys the stream.
Viewing Information about Endpoints
You can use the Network Stream Endpoint properties to view information about endpoints. Complete the following steps to use Network Stream Endpoint properties.
- Add the Property Node (Network Stream Endpoint) to the block diagram.
- Wire an endpoint refnum wire to the reference input on the property node. Obtain this reference from the reader endpoint reference of the Create Network Stream Reader Endpoint function, the writer endpoint terminal of the Create Network Stream Writer function, or the endpoint out terminal of any of the other Network Streams functions.
- Right-click the Property terminal of the Network Stream Endpoint Property Node and select Select Property from the shortcut menu to select the property you want to use.
- (Optional) Use the Positioning tool to resize the Network Stream Endpoint Property Node to display more than one property simultaneously.
The following figure shows an example of using the Network Stream Endpoint properties.
In this example, subtracting the Available Elements for Writing property from the Buffer Size property indicates the number of elements in the buffer of the writer endpoint.