• 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
Re: [NSHost currentHost] halts app for 2s on Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >[NSHost currentHost] halts app for 2s on Leopard (From: Mark <email@hidden>)
 >Re: [NSHost currentHost] halts app for 2s on Leopard (From: Gerd Knops <email@hidden>)

  • Prev by Date: Re: Leopard performance penalty (3x slower), NSPopAutoreleasePool
  • Next by Date: Re: Safe asynchronous file copies
  • Previous by thread: Re: [NSHost currentHost] halts app for 2s on Leopard
  • Next by thread: Re: [NSHost currentHost] halts app for 2s on Leopard
  • Index(es):
    • Date
    • Thread