Example Program Drafts

Showing results for 
Search instead for 
Did you mean: 

Dynamic bi-directional ethernet connection between multiple targets


Code example that manages multiple, bi-directional ethernet links between unknown targets across processes or LAN


The problem people often have to deal with is connecting to an unknown number of RT or Windows targets or applications across a network, and managing those connections when either end may suddenly disappear. I've been messing about, on and off, trying to make an efficient, reusable connection mechanism that avoids the complications of all of the other approaches I've seen.

The attached code works on a master / multiple-slave basis. The slaves publish their existence with UDP broadcasts. If the process name matches the master, it adds it to it's list and opens a TCP/IP connection to it. All of the communication is through string data types (anything can be flattened into a string) The code establishes connections from a single master to any number of slaves that reference the same process name. You can have multiple masters with different process names but don't use two masters with the same process name or only one will get the connection to each slave. If that master falls over, another with the same process name will take over.

Here is the first version I'm making available. The problem it still has is that it doesn't work if you have a VPN connection active. It doesn't work because the UDP broadcasts identifying the devices on the network are sent over the wrong network (not the LAN subnet). The more cases I tried to cover the more complicated the code became, which defeated the original idea So I've cut it back to keep it simple.

Either end of the link can be shut down and re-started whenever you like. The connection list is managed for you so all you see is the inbound and outbound traffic by the ip and also a unique string. This random string is to allow multiple targets on the same machine. Outbound data can be sent to a single slave or you can use 255s in the ip address octets to broadcast messages it to all slaves.


I will upload a better documented version at some point but I want to get this provisional code out as it is relatively simple to use if you look at the examples and there are a few people who have been asking for the functionality.

Please leave any feedback for additional features.

Steps to Implement or Execute Code

Unzip the attached file and open the project. The connection handler is contained in an lvlib which is in the included .llb file. I've included a master and slave example. These are vi template files so that the example launcher can create multiple instances on the same machine to demonstate how it works. It's written in 2013 SP1 but doesn't use anything but standard code.



LabVIEW 2013 SP1

The Service Locator service should not be disabled.

Works on Windows, RT and probably Linux (but I haven't tried it).