Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > getting FQDN via cocoa

getting FQDN via cocoa
Thread Tools
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Aug 14, 2002, 11:43 PM
 
say my ip is 12.345.67.89
but my fully qualified domain name is sp1-12.345.67.89.charter-stl.com
(as listed in sharing system pref pane)
how can my app get the users FQDN not just the ip?
3R1C
     
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
Aug 15, 2002, 08:13 AM
 
Originally posted by 3R1C:
how can my app get the users FQDN not just the ip?
Try:

Code:
NSString *hostName = [[NSHost currentHost] name];
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Aug 15, 2002, 10:25 AM
 
That gives like the name of the machine. In my case 'Mobius'.
3R1C
     
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
Aug 15, 2002, 12:16 PM
 
Originally posted by 3R1C:
That gives like the name of the machine. In my case 'Mobius'.
Ah, on my machines it's giving me the fully qualified name, but they both have static IP's. I don't have a means of testing it with, say, a name assigned by a DHCP server.

That being said, have you tried going through the names array returned by NSHost (i.e. [[NSHost currentHost] names])? That gives me both the FQDN and "localhost".
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Aug 15, 2002, 03:27 PM
 
that gives 3 diff names.

mobius
mobius.home.charter-stl.com
localhost

the middle one is close, but not right.

i do utillize dhcp.
3R1C
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Aug 16, 2002, 01:41 AM
 
well, im getting closer.
I found something called nslookup. This returns right info amoung other info.

like this:


[mobius:~] xaos01% nslookup 12.34.56.78
Server: ns1.charter-stl.com
Address: 24.217.0.3

Name: SP1-12.34.56.78.charter-stl.com
Address: 24.207.212.127


the Name line is the good line.
so should I just slap this in an NSTask and parse out the good stuff?
do all installs of osx have nslookup?
does this ring any bells for people who know cocoa as to a better way to accomplish this?
3R1C
     
Fresh-Faced Recruit
Join Date: Aug 2002
Status: Offline
Reply With Quote
Aug 16, 2002, 04:38 PM
 
You can use standard c within objective-c. So take a look at gethostbyaddr() .
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:10 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2