• 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
NSHost currentHost Slow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSHost currentHost Slow


  • Subject: NSHost currentHost Slow
  • From: John Tsombakos <email@hidden>
  • Date: Tue, 4 Jan 2005 01:23:27 -0500

I'm trying to track down this problem. It started with Safari taking a long time connecting to websites. (I enter a URL, hit return and the status line says "Connecting to...." for several seconds - up to almost a minute in some cases). (This is OS X 10.3.7, btw)

I saw a discussion on Apple's support pages saying the problem is with [NSHost currentHost]. This does a reverse lookup and when it fails, it keeps trying. And they seem to have noticed that when your IP address is set through a cable/DSL router (like my Linksys BEFSR41), to something in the 192.168.x.x range, it triggers the problem. Some found out that setting it so your IP range is 10.x.x.x, makes the problem lessen. I tried changing it and it helped, but still seems to take a while.

So I set up a little sample to see:

#import <Foundation/Foundation.h>

int main() {
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSDate *start, *end;
	NSHost *h;

	[NSHost setHostCacheEnabled:NO];
	start = [NSDate date];
	h = [NSHost currentHost];

	end = [NSDate date];
	NSLog(@"Time elapsed: %f", [end timeIntervalSinceDate:start]);

	[h release];
	[NSHost flushHostCache];
	start = [NSDate date];
	h = [NSHost currentHost];

	end = [NSDate date];
	NSLog(@"Time elapsed: %f", [end timeIntervalSinceDate:start]);

	[pool release];
	return 0;
}

I did it twice to see if it would be any different. I also put in the calls to turn off the caching, but that didn't make any difference.

Here are my sample times.. you can see the first call takes upwards of 10 seconds:

[farside:~/Devel] john% ./a.out
2005-01-04 01:14:29.286 a.out[542] Time elapsed: 5.073724
2005-01-04 01:14:29.287 a.out[542] Time elapsed: 0.000212
[farside:~/Devel] john% ./a.out
2005-01-04 01:14:37.750 a.out[543] Time elapsed: 8.439076
2005-01-04 01:14:37.751 a.out[543] Time elapsed: 0.000215
[farside:~/Devel] john% ./a.out
2005-01-04 01:14:42.839 a.out[544] Time elapsed: 5.063639
2005-01-04 01:14:42.839 a.out[544] Time elapsed: 0.000208
[farside:~/Devel] john% ./a.out
2005-01-04 01:14:52.952 a.out[545] Time elapsed: 10.088655
2005-01-04 01:14:52.953 a.out[545] Time elapsed: 0.000213

(and then of course when I tried again, I was getting sub-second times-it seems to "fix" it self briefly, then go back to being bad:)
[farside:~/Devel] john% ./a.out
2005-01-04 01:21:33.339 a.out[555] Time elapsed: 0.056584
2005-01-04 01:21:33.339 a.out[555] Time elapsed: 0.000207
[farside:~/Devel] john% ./a.out
2005-01-04 01:21:33.731 a.out[556] Time elapsed: 0.056105
2005-01-04 01:21:33.731 a.out[556] Time elapsed: 0.000213
[farside:~/Devel] john% ./a.out
2005-01-04 01:21:34.081 a.out[557] Time elapsed: 0.047007
2005-01-04 01:21:34.082 a.out[557] Time elapsed: 0.000012


This may be a bit off topic, but since it's NSHost that seems to be the problem, I figured I'd post my findings.

Thanks!

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


  • Follow-Ups:
    • Re: NSHost currentHost Slow
      • From: j o a r <email@hidden>
  • Prev by Date: Re: OgreKit, onigurama, and named groups
  • Next by Date: Re: OT request: Shareware anti-cracking - need info
  • Previous by thread: Re: NSBox addSubview positioning
  • Next by thread: Re: NSHost currentHost Slow
  • Index(es):
    • Date
    • Thread