• 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: Jeff Harrell <email@hidden>
  • Date: Wed, 18 Jun 2003 01:13:42 -0500

Keywords: mDNS, reverse-lookup, Rendezvous, hostname

(Lloyd and I have been exchanging messages in private. This is for the list archives.)

As I understand it, what Lloyd wants is to be able to take an IP address extracted from a struct sockaddr provided by Rendezvous and turn that into a hostname. This doesn't work in a Rendezvous-only environment because Rendezvous can translate hostnames in the .local. domain to IP addresses, but not the other way around. (Which makes sense, if you think about it. In an ad hoc network environment, if you have an IP already, you're probably not going to need to turn it into a name. Only the other way around.)

My suggestion to Lloyd (which probably won't help much) was to put the computer's Rendezvous hostname into the name field of the NSNetService instance. Like this:

NSNetService* service = [[NSNetService alloc] initWithDomain:@""
type:@"_something._tcp."
name:[[NSProcessInfo processInfo] hostName]
port:portNumber];
[service setDelegate:self];
[service publish];

As long as HOSTNAME is set to -AUTOMATIC- in /etc/hostconfig, [[NSProcessInfo processInfo] hostName] returns the Rendezvous name as defined in System Preferences.

That's the best suggestion I have. If nobody else has a better one, then this will be sitting there in the archives when somebody else goes searching for it.

On Wednesday, June 18, 2003, at 12:42 AM, Lloyd Dupont wrote:

[foo name] gives me the name of the service, NOT the name of the computer (and I display in a table view:
- computer name
- service 'state')

and addresses gives me a list of struct sockaddr. (holding IP, and not host name)

still need the friendly computer name.
one I could ping, or use with NSSocketPort as the user is able to edit the list manually to monitor the services running on computer without rendezvous .....

On Wednesday, June 18, 2003, at 03:03 PM, Jeff Harrell wrote:

Why don't use you the name attribute of the NSNetService instance?

One of the assumptions about Rendezvous is that it shouldn't matter to the user where a service is located; things like the IP address (and, by extension, hostname) and the port number are abstracted away. The name property is intended to be a human-readable >> identifier.

I don't know anything about what you're doing, but in the absence of any other information [foo name] (for some NSNetService instance foo) is probably what you ought to use.

On Tuesday, June 17, 2003, at 11:34 PM, 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.

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

I don't understand, if I 'ping ihookIT.local', (the rendezvous name) it work, even from a remote computer. why NSHost hasn't a clue ?
Anyway could you suggest me an other way to get a host name from an IP ?
_______________________________________________
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.



--
email@hidden
http://homepage.mac.com/jharrell
_______________________________________________
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.
_______________________________________________
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.



--
email@hidden
http://homepage.mac.com/jharrell
_______________________________________________
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.

  • Follow-Ups:
    • Re: HowTo get computer name from IP
      • From: Lloyd Dupont <email@hidden>
References: 
 >Re: HowTo get computer name from IP (From: Lloyd Dupont <email@hidden>)

  • Prev by Date: Re: HowTo get computer name from IP
  • Next by Date: Re: HowTo get computer name from IP
  • Previous by thread: Re: HowTo get computer name from IP
  • Next by thread: Re: HowTo get computer name from IP
  • Index(es):
    • Date
    • Thread