Example Code

Example TCP Watchdog VI in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI provides a watchdog that will monitor network connectivity, and will attempt to reconnect in the event of failure.

 

Description

This VI needs to be modified to suite your needs. In its current state it will make 10 attempts to connect to an IP address and port 8080.You can easily modify this code to cycle through a number of ports or IP addresses to re-establish a connection. If it fails to connect it will return an error. The VI also allows you to rule out network connection issues as the cause of your application misbehaving.

 

Requirements

  • LabVIEW 2013 (or compatible).

 

Steps to Implement or Execute Code

  1. Enter the IP Address and Port of the network connections.
  2. Run the program.
  3. If network connection is successful, the program will exit.
  4. If it fails, the program will attempt to reconnect a few times.

Additional Information or References 

Main VI Block Diagram

capture.JPG

 

**This document has been updated to meet the current required format for the NI Code Exchange."

Tim, CLD, CTD
National Instruments (UK & Ireland)
________________________________________________
"No problem is insoluble in all conceivable circumstances"

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.