• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Stale DNS Cache Problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stale DNS Cache Problem?


  • Subject: Stale DNS Cache Problem?
  • From: dayglojesus <email@hidden>
  • Date: Sat, 15 Dec 2012 19:52:26 -0800

Greetings,

I am having some trouble writing a method that can reliably resolve an IP address to host name.

I have attempted to use 2 different techniques: NSHost and CFHost. Both of these techniques appear to have the same difficulty resolving a hostname after a network transition has occurred.

An example, in it's simplest form:

// Resolve a single IP address and return the first hostname
// Yes, this blocks. No, this is not thread safe.
- (NSString *) resolveIPaddress:(NSString *)ipAddress
    NSHost *host = [NSHost hostWithAddress:ipAddress];
    name = [host name];
    if (name == nil) {
        NSLog(@"name is nil");
name = @"<name_resolution_error>";
// Using CFHost the error returned is: 12,8
    }

    

    return name;
}

If I run the code above, sometimes the name is returned, sometimes it is not.

If the name _is_ returned, forcing some kind of network transition, downing an interface for example, and running the code again will produce the expected result: a nil name.

Now, if I bring the interface up again and run the code, I would expect that ipAddress *should* resolve -- it does not. 

However, if I flush the DNS cache (as per: http://support.apple.com/kb/HT5343?viewlocale=en_US&locale=en_US) and run the code again, it resolves!

Again, this happens whether or not I use any of the above techniques, synchronously or asynchronously.

I am fairly new to programming -- perhaps I lack some fundamental understanding here?

Hoping someone can enlighten me.

Thanks!

--
Brian W.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Stale DNS Cache Problem?
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Prev by Date: Re: Peer-to-peer SSL/TLS best practices/strategy
  • Next by Date: CoreWLAN CWKeychainCopyPassword() Linker issue
  • Previous by thread: Re: Peer-to-peer SSL/TLS best practices/strategy
  • Next by thread: Re: Stale DNS Cache Problem?
  • Index(es):
    • Date
    • Thread