 |
 |
getting FQDN via cocoa
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
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
|
|
Originally posted by 3R1C:
how can my app get the users FQDN not just the ip?
Try:
Code:
NSString *hostName = [[NSHost currentHost] name];
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
That gives like the name of the machine. In my case 'Mobius'.
|
3R1C
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Sep 2000
Status:
Offline
|
|
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".
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
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
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2001
Status:
Offline
|
|
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
|
|
You can use standard c within objective-c. So take a look at gethostbyaddr() .
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |