Skip navigation.
 
mlRe: [NSHost currentHost] halts app for 2s on Leopard
FROM : John Stiles
DATE : Sat Nov 17 22:30:25 2007

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_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/jstiles%
> 40blizzard.com
>
> This email sent to <email_removed>

Related mailsAuthorDate
ml[NSHost currentHost] halts app for 2s on Leopard Mark Nov 8, 15:19
mlRe: [NSHost currentHost] halts app for 2s on Leopard Gerd Knops Nov 17, 19:02
mlRe: [NSHost currentHost] halts app for 2s on Leopard John Stiles Nov 17, 22:30
mlRe: [NSHost currentHost] halts app for 2s on Leopard Rob Keniger Nov 18, 03:37