Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have C# code which takes x3 longer to execute on W2008R2 vs W7

the code is very simple (getting host name):

        Stopwatch sw = new Stopwatch();
        sw.Start();

        IPHostEntry ip = Dns.Resolve(Dns.GetHostName());
        string s = ip.HostName;

        sw.Stop();

        Console.WriteLine(sw.ElapsedTicks);
        Console.WriteLine(s);

I did stop some services on W2008. May be I accidentally stopped something which helps to propagate DNS notifications or whatever...

Any thoughts?

EDIT: I am sorry I havent told. The x3 means: on W7 it takes <1ms and on W2008 it is either 2 or 9ms... It is not really about timing out.

share|improve this question
1  
Do the two machines have the same DNS settings? Is the Win2008 box running a DNS server? –  Zoredache Jun 23 '10 at 19:33
    
Are you trying to resolve the same host name? Are you flushing the DNS cache on both of your test systems before running your test? –  joeqwerty Jun 23 '10 at 20:37
    
No DNS server on either of them. Settings - DNS provided by ISP (two different providers as the computers in different places). –  Boppity Bop Jun 23 '10 at 22:43
    
@Joe - how do I flush DNS cache? –  Boppity Bop Jun 23 '10 at 22:43
1  
On a Windows machine: from a command prompt type: ipconfig/flushdns –  joeqwerty Jun 23 '10 at 22:55
show 4 more comments

1 Answer

up vote 1 down vote accepted

What happens when you try resolving that name (or any other name) outside of your program, f.e. using ping or nslookup?

The application should run exactly the same on both computers regardless of the O.S., so this might very well be a DNS problem. If the machine's name is not registered in the DNS server(s) the machine is using, or if the machine can't reach at all its configured DNS server(s), or if the server(s) can't resolve the name, or (many other possible issues here), the query will fail and/or timeout, and only then it will be resolved using the local hosts file.

You should definitely check your DNS configuration.

share|improve this answer
1  
I thought the hosts file was checked before doing a DNS lookup? –  Ben Pilbrow Jun 23 '10 at 19:47
    
Actually it should, but if you open it in Windows 7/200R2, you'll see a comment saying "local host name resolution is handled within DNS now"... –  Massimo Jun 23 '10 at 19:54
    
guys sorry. You lost me here. The host name is the name of the computer running that program. So it is name like MYSUPERDUPERPC - the one I set in System -> Computer name. The both computers are far apart - W7 is at home in the UK and W2008 in US. Both machines uses some other DNS from ISP. No local DNS on them. Tell me - is it going to lookup through DNS servers to find out the name of the local host?? –  Boppity Bop Jun 23 '10 at 22:40
    
ok. I just tried ping MYSUPERDUPERPC and it works similar on both machines. it shows <1ms ping and no delays. –  Boppity Bop Jun 23 '10 at 22:41
    
flushdns doesnt work. perhaps I stopped necessary service.... –  Boppity Bop Jun 24 '10 at 18:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.