Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
33 ratings:
 4.18 out of 5     Rate this Document

Programmatically Obtain a Computer's IP Address Using LabVIEW or LabWindows™/CVI

Primary Software:
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software:

How do I programmatically read the IP address of my computer using LabVIEW or LabWindows™/CVI?

From LabVIEW
The String to IP function, from the TCP palette, can be used to read the IP address of a computer. To do this, place a String to IP function on the block diagram. If the name terminal of the function is left unwired, net address returns the IP network address of the current machine.

To convert this to the machine name or to the standard dot format for IP addresses, an IP to String function should be placed on the block diagram. Then, the output of the string to IP function should be wired to the net address terminal on the IP to String function. Wiring a true constant to the dot notation terminal will return the IP address in dot-notation format. Dot-notation format returns an IP address in the form If the dot notation terminal is left unwired, or if a false constant is wired to it, it returns the IP address in the form

To obtain all of the IP addresses of the computer, right-click the String to IP function and select Multiple Outputs, so that there is a check placed next to the option. The function will now output an array of IP addresses, so you must index the array in order to convert the IP address to a string using the IP to String function. One implementation, using the Index Array function, can be seen in the figure below.

From LabWindows/CVI

To find the IP address of a machine using LabWindows/CVI, you can call the GetTCPHostAddr function. This function obtains the default IP address of the computer on which your program is currently running. To obtain all the IP addresses of the computer, call GetAllTCPHostAddresses.

Note: This is not supported in LabVIEW Real-Time.

Related Links:
KnowledgeBase 3ENE8DL2: Programmatically Converting a Hostname to an IP Address in LabVIEW
KnowledgeBase 3B6BTU4B: Return IP Address Instead of Machine Name in TCP and/or TCP Wait on


Report Date: 06/08/2007
Last Updated: 06/08/2012
Document ID: 4A7G1N97

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit