• 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] name] blocking on 10.6 ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[[NSHost currentHost] name] blocking on 10.6 ?


  • Subject: [[NSHost currentHost] name] blocking on 10.6 ?
  • From: "email@hidden" <email@hidden>
  • Date: Tue, 8 Sep 2009 21:15:18 +0100

I am not sure if this is a problem unique to me or not but under 10.5 [[NSHost currentHost] name] or [[[NSProcessInfo] processInfo] hostname] were quick and easy ways to get an mDNS friendly hostname such as imac-2.local

On 10.6 I find that both these combinations block badly (NSProcessInfo merely defers to NSHost I think).

The list has a few references to the possibility of these blocking but I never encountered it until now.
According to a stack sample getnameinfo() seems to be the library call that is blocking.
_mdns_query_mDNSResponder seems to be the actual blocking call.


Anyone else seeing this behaviour?

There seem to be two alternatives:

NSString *name = NSMakeCollectable(SCDynamicStoreCopyLocalHostName (NULL));

This gives the correct mDNS friendly hostname but omits the local pseudo domain.

Otherwise this seems suitable:

char hostname[_POSIX_HOST_NAME_MAX + 1];
gethostname(hostname, _POSIX_HOST_NAME_MAX);
name = [NSString stringWithCString:hostname encoding:NSUTF8StringEncoding];


Jonathan Mitchell

Developer
http://www.mugginsoft.com





_______________________________________________

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


  • Follow-Ups:
    • Re: [[NSHost currentHost] name] blocking on 10.6 ?
      • From: Brent Gulanowski <email@hidden>
    • Re: [[NSHost currentHost] name] blocking on 10.6 ?
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: NSURLDownload delegate methods seperate thread
  • Next by Date: Re: NSImage with multiple representation sizes
  • Previous by thread: Re: Continuous NSTextField not updating bound value continuously?
  • Next by thread: Re: [[NSHost currentHost] name] blocking on 10.6 ?
  • Index(es):
    • Date
    • Thread