LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way for LabVIEW to know if the computer has an ethernet connection active?

I need to know in my VI if the computer has a network connection, to avoid trying to connect through TCP/IP when the connection is not available. I would prefer to know if there is a connection available rather than rely on errors coming from the TCP/IP functions not being able to connect.

Windows instantly knows when a network cable is unplugged. Is there a function in LabVIEW that can similarly instantly detect a connection?

Or, does anybody know if there is a Windows-provided dll that contains the function that the taskbar indicator uses to know if there is a connection present. If there is, then I could call the dll from LabVIEW and know the connection status.

Thanks.

Alejandro
0 Kudos
Message 1 of 3
(2,351 Views)
You could use System Exec to run the ipconfig command and parse the return string. You'll get a Media State:Cable Disconnected when the cable is unplugged.
Message 2 of 3
(2,343 Views)
Hi there,

there`s an API

unsigned long WNetAddConnectionA(CStr lpRemoteName, CStr lpPassword, CStr lpLocalName);

in mpr.dll.

lpRemoteName the address of a network resource (e.g. "\\YOURSERVER\YOURDRIVE")
lpPassword may be NULL
lpLocalName should be NULL, otherwise the API maps lpRemoteName to the drive you specify in lpLocalName (e.g. lpLocalName = "e:")

if all is ok, the API returns 0, otherwise some errorcodes.

more info can be found here

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection.asp

best regards
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 3
(2,316 Views)