Example Code

Serverless UDP Chat using 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 is a UDP-based chat application that runs without a server.  

 
Description
This UDP-based chat application runs without a server. This is accomplished via UDP multicast where chat clients multicast messages to other clients within range.  All clients keep track of one another's presence and status via multicast announcements, public queries, and responses. Communication is done on three ports: message send, message receive, and command ports.

The application has five main sections:

  1. Initialize variables
    • Set up port numbers
    • Obtain window handle for notifications
    • Set "Running" state to TRUE
  2. Establish port resources
    • Command port
    • Send port
    • Receive port
  3. Announce joining chat
    • Verify user has entered valid name
    • Send message on command port to announce presence
    • Send message in chat to announce joining
  4. Running
    • Send and receive messages
    • Search for other users
    • Process status updates from other clients
  5. Exit
    • Send message on command port to announce leaving
    • Send message in chat to announce leaving
    • Close ports
    • Close Front Panel if loaded as exe

 

Requirements

  • LabVIEW Base Development System 2012 (or compatible)


Steps to Implement or Execute Code

  1. Unzip the attached folder to your computer.
  2. Open the project "Serverless UDP Chat 2012 NIVerified.lvproj"
  3. Open the VI under Main Application folder.
  4. Run the VI.
  5. Type in Name to be used for chatting and click Done.
  6. Type in Message to be displayed and click Send or press Enter on the keyboard.
  7. Click Change Name to alter name to be used for the chat.
  8. Click Clear message to clear the chat history.
  9. Click EXIT to exit from the chat.

 

Additional Information or References
VI Front Panel

キャプチャ.PNG

 

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

Regards,
Chris Elliott
x36772

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