Programmatically Obtain a Computer's IP Address Using LabVIEW or LabWindows™/CVI
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
How do I programmatically read the IP address of my computer using LabVIEW or LabWindows™/CVI?
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 22.214.171.124. 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 machinename.domain.com.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.
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.
KnowledgeBase 3ENE8DL2: Programmatically Converting a Hostname to an IP Address in LabVIEW
KnowledgeBase 3B6BTU4B: Return IP Address Instead of Machine Name in TCP Listen.vi and/or TCP Wait on Listener.vi
Report Date: 06/08/2007
Last Updated: 06/08/2012
Document ID: 4A7G1N97