LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check network availability?

Hello,
I need to permanently check the availability to a specified directoy path. (e.g. X:\Data\Project1\", where X:\ is a drive on a LAN network)
 
I therefore create a thread which checks this path every 3 seconds.
My problem is that all check methods I tried have a very high timeout time.
 
First attempt: (Write & Read a dummy file)
1) OpenFIle(..)
2) WriteInFile(..)
 
--> the OpenFile function from the FormatIO Library stalls for approx. 90 seconds if the drive X: is not available, until it reports a timeout
 
Second attempt:
us the function GetFileWritability(..) from the Toolbox library,  - this one has approx.a 20 seconds timeout
 
I'd like to get response times of one second or lower. So if someone pulls the ethermet connection from the server, I somehow need to know within that time.
 
 
Questions:
 
  • Are there other ways to check the connectivity?
  • Can I somehow lower the timeout values for the above functions?
Thanks for your help!
Greg
 
.
0 Kudos
Message 1 of 4
(3,873 Views)
Why not ping the server in the network? Ping has a timeout of don't know 10 sec, but when you do the pinging in a thread, you will get immediately a (good) response, otherwise the thread will handle the timeout. And you can check, if thread is running (waiting) for the server more than 2 sec, network has gone.

Hope that helps

Peter
Message 2 of 4
(3,868 Views)

Hi Peter,

thanks for the hint. I even found the "InetPing" function in the CVI Internet Library, where I can set the Timeout.

Now there's only one problem left. The InetPing function requires an IP address or a network name. All I have is the drive name from the standard windows file dialog.

How can I get the IP Adressof a machine where a drive name is located?

 

Thanks again,

Greg

 

0 Kudos
Message 3 of 4
(3,861 Views)
not sure, can you use "net use" in a cmd-box and parse the result?
0 Kudos
Message 4 of 4
(3,855 Views)