Re: [NSHost currentHost] halts app for 2s on Leopard
Re: [NSHost currentHost] halts app for 2s on Leopard
- Subject: Re: [NSHost currentHost] halts app for 2s on Leopard
- From: Gerd Knops <email@hidden>
- Date: Sat, 17 Nov 2007 12:02:35 -0600
On Nov 8, 2007, at 8:19 AM, Mark wrote:
Hi list,
I've tracked why my app seems to halt for about 2s.
Culprit is [NSHost currentHost] on Leopard (on Tiger that was fast).
Does anybody know another way of getting the current host ip and name?
Confirmed here for 10.5.0 and 10.5.1. It also seems to involve a DNS
lookup, and if there is a DNS problem, the delay will be a lot longer.
In my code I replaced it with the code below. Note that it is not
equivalent (read the applicable manual pages), but for many situations
sufficient, and always fast.
Gerd
- (NSString *)currentHost {
char s[_POSIX_HOST_NAME_MAX+1];
gethostname(s,_POSIX_HOST_NAME_MAX);
return [NSString stringWithCString:s encoding:NSUTF8StringEncoding];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden