Connections to Network Variables
- Updated2023-02-21
- 3 minute(s) read
The LabWindows/CVI Network Variable Library provides the following types of connections to network variables:
![]() |
Note National Instruments recommends using the Subscriber or Buffered Subscriber connections for reading and the Buffered Writer connection for writing as these connections are more efficient that the Reader, Asynchronous Reader, and Writer connections. |
- Subscriber—The server automatically sends new data to your program, and your data callback function is called with the new data.
- Buffered Subscriber—The server automatically sends new data to your program where the item is buffered. You can get the items from the buffer individually by calling the CNVGetDataFromBuffer function. This function indicates if the buffer is empty, if items in the buffer got overwritten by new items, or if you are reading a stale item. You can configure the size of the buffer and change it at any later time.
- Writer—You can send data to the server using the CNVWrite function. This function waits until the data reaches the server.
National Instruments recommends that you create non-buffered writer connections for low latency use cases. - Buffered Writer—You can call the CNVPutDataInBuffer function to buffer the data to be written on the client. This causes the data to be sent asynchronously to the server. This function does not wait for the data to reach the server. Your data-transferred callback function is called when the data reaches the server. You can reduce network traffic if you do not provide a data-transferred callback. You can configure the size of the buffer and change it at any later time.
National Instruments recommends that you create buffered writer connections for high throughput use cases. - Reader—The server does not automatically send data to your program. You can call the server to read the data using the CNVRead function. If there is no new data on the server, the function waits for new data until the wait time you specify has elapsed.
- Asynchronous Reader—The server does not automatically send data to your program. You can call the server to asynchronously read the data using the CNVReadAsync function. Your data callback function is called when the data is available.
Note The throughput rate of data with Reader and Asynchronous Reader connections is slower than with Subscriber and Buffered Subscriber connections. If throughput rate is critical to your application, consider using a Subscriber or Buffered Subscriber connection instead.
For all connections, changes in connection status are notified by calling your status callback function with the new status. Connection status events occur when there is a significant network delay and NI-PSP attempts to reconnect.
When you finish using a connection, you must dispose the connection handle using the CNVDispose function.