Re: HowTo get computer name from IP
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.