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: John Stiles <email@hidden>
- Date: Sat, 17 Nov 2007 13:30:25 -0800
I'd note that +NSString stringWithUTF8String: will do the same thing
as your +NSString stringWithCString:encoding:, and goes back a lot
further, old-OS-compatibility-wise.
On Nov 17, 2007, at 10:02 AM, Gerd Knops wrote:
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:
40blizzard.com
This email sent to email@hidden
_______________________________________________
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