Reputation: 3305
I'm opening directories over network using:
System.Diagnostics.Process.Start(path); // path = UNC network path
But having 2 network paths:
\\This_PC_Does_Not_Exist\dir
\\This_PC_Is_Turned_Off\dir
How come first one takes very fast to verify that the network PC doesn't exist, while 2nd takes around two minutes? If I'm not wrong it's 30 seconds in Windows environment to determine if network path is unreachable.
Why does it take so long in this case and how to speed up the info that PC is off?
Upvotes: 9
Views: 1113
Reputation: 86818
In order to load the file, Windows must first make a file sharing connection to the machine. First it looks up the UNC name to get the IP address. If the machine doesn't exist, it can't get an IP address, and it fails quickly (as in the first example). If it does exist (as in the second example), Windows must then attempt to connect.
So why does it take two minutes when the time out is supposed to be 30 seconds? One possibility is that it retries a few times. Another possibility is that you have different network protocols and it has to try each one.
Upvotes: 7
Reputation: 2346
A faster way to check if the computer is on would be to ping the computer. Specify any timeout you like. There should be a response within a few seconds...
I guess the slow response has to do something with that the name of the turned off computer is still known in the network and associated with an ip. Then a longer timeout is chosen since the computer should be there...
Upvotes: 1