• 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: HowTo get computer name from IP
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HowTo get computer name from IP


  • Subject: Re: HowTo get computer name from IP
  • From: j o a r <email@hidden>
  • Date: Wed, 18 Jun 2003 08:45:27 +0200

On Wednesday, Jun 18, 2003, at 06:34 Europe/Stockholm, Lloyd Dupont wrote:

I get an IP address (from NSNetServiceBrowswer) of a remote computer.
I try to get a friendly name to display to the user.

As a follow up to my previous post, and extracted from the tech note I quoted, this works on Mac OS X 10.1 and later:

CFStringRef result = CSCopyMachineName();
NSLog(@"Machine name: %@", (NSString *)result);

Machine name: My Computer

I'm using NSHost for that, and didn't deliver me any name !
although I do my test on localhost !

It works on my machine:

NSLog(@"Host names: %@", [[NSHost currentHost] names]);

Host names: <CFArray 0x215600 [0xa01303fc]>{type = mutable-small, count = 2, values = (
0 : <CFString 0x215640 [0xa01303fc]>{contents = "imac.joar.com"}
1 : <CFString 0xa07e53a4 [0xa01303fc]>{contents = "localhost"}

It could perhaps depend on your DNS server setup?

j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >HowTo get computer name from IP (From: Lloyd Dupont <email@hidden>)

  • Prev by Date: Re: [ANN] The Cocoa 3D Tutorial project has a web page! (and a new release)
  • Next by Date: libcrypto warning
  • Previous by thread: HowTo get computer name from IP
  • Next by thread: Re: HowTo get computer name from IP
  • Index(es):
    • Date
    • Thread