This document describes a server application design pattern that supports multiple client connections. It extends the command-based STM communication example to handle dynamic connections and disconnections.
Client/server systems provide access to a central application from one or more remote clients. For example, a server application may perform some measurement or automation function (such as test cell control) and client applications may provide operators with a user interface for monitoring the state or progress of that function.
In multi-client applications, clients may connect and disconnect at random times. For example, during HIL batch tests that run for extended periods of time, various users may connect to the system several times a day to check on the progress and status of test that are of interest to them.
The example provides a design pattern for implementing an application that provides a single network-based server and has multiple clients connect to the server to exchange data between client and server. It uses the STM (Simple Messaging) Reference Library for data communication between client and server.
The example application has the following features:
Simulates the acquisition of 4 data channels
Accepts connections from any number of clients
Receives commands such as stop and desired channel from the client
Sends data to each of the connected clients. Each client only receives the data they requested.
Client (each client is identical)
Connects, disconnects and reconnects to the server
Sends commands such as stop and desired channel
Receives data from the server and displays it on a graph
Figure 1. Multi-client Server Overview
Steps to Run Example
Open the STM Multi Client Server Example project.
From the project open the STM Multi-Client - Server VI.
Open the STM Multi-Client - Client VI template, or create multiple client VIs from the template VI using the New VI from Template option in LabVIEW.
Run the server VI.
Set the Target IP address in each client to match the IP address of the server. Run each client VI.
Change the Channel setting in the client to choose a different waveform.
LabVIEW Full Development System, version 2010 or later
authored by Christian L, CLA Principal Systems Engineer - Partner and Ecosystem Development - National Instruments
Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code, and use of the Code is subject to the Sample Code License.