9

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?

yosh
  • 3,245
  • 7
  • 55
  • 84

2 Answers2

7

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.

Gabe
  • 84,912
  • 12
  • 139
  • 238
  • Is there any way to limit it? I've had a look at Process.StartInfo but it doesn't seem to have any parameters that might help. – yosh Sep 30 '11 at 09:49
  • @yosh: If you want, there is probably a registry setting that can lower that 30 second timeout. I don't know it, but maybe you can ask on superuser. – Gabe Sep 30 '11 at 16:23
  • Hm, I was hoping to programmatically limit access with "no retry" and "use tcp only", without modifying anything out of application. Thanks! – yosh Oct 03 '11 at 08:23
1

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...

erikH
  • 2,286
  • 1
  • 17
  • 19
  • Many computers do not have ping enabled (ICMP ECHO blocked by the firewall). – Gabe Sep 30 '11 at 01:57
  • Hm, it's still worth to check. Ping with timeout might not be the ideal solution but could work in this case.. – yosh Sep 30 '11 at 09:36