 |
 |
gethostbyname() returns NULL
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Status:
Offline
|
|
I am doing some Unix server development at the University on Solaris. We are interested in porting to Linux and OS X.
I can get the software to compile on LinuxPPC and, after adding a few header includes, on OS X. Since my Mac is on a cable modem at home, my hostname is localhost in both Linux and OS X. For Linux, I used 'hostname' and 'alias HOST=...' to change my hostname to what my cable company shows my machine as to get the server software to run.
I tried doing the same on OS X. I used 'hostname' and 'setenv HOST ...' while using sudo tcsh. I used uname to confirm my changes. I also used 'kill -HUP xxx' to restart lookupd per Apple's TIL since it caches host info.
When I try the server software, however, gethostbyname() returns NULL. herror says that the error is 'Unknown Host'.
Does anyone have any suggestions?
Scott
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Boston, MA
Status:
Offline
|
|
edit /etc/hostconfig and reboot.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Status:
Offline
|
|
Thanks for the suggestion. I edited the file and changed
hostname=-AUTOMATIC-
to
hostname="my-cable-modem-name"
I then rebooted. Both 'echo $HOST' and 'uname -a' returned the new info. But gethostbyname still returns NULL and herror shows 'Unknown Host'.
Should I be doing something else?
Scott
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2001
Location: San Francisco, USA
Status:
Offline
|
|
Originally posted by my 2 cents:
<STRONG>I then rebooted. Both 'echo $HOST' and 'uname -a' returned the new info. But gethostbyname still returns NULL and herror shows 'Unknown Host'.
Should I be doing something else?</STRONG>
I'm not sure how you are using gethostbyname(), but perhaps you could run a similar test using nslookup. If nslookup fails with 'unknown host', then you have a configuration problem. Make sure your search domains are specified in the Network Preferences. Your changes will be reflected in /etc/resolv.conf. If nslookup works and your code does not, check your code for possible bugs.
To continue your example, if your full hostname is 'my-cable-modem-name.my-cable-provider.com', then make sure 'my-cable-provider.com' is listed in the search domains. You can use the following link to find your full hostname:
http://www.dyndns.org/cgi-bin/check_ip.cgi
Edit: fixed a typo.
[ 06-18-2001: Message edited by: honeydew ]
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: May 2001
Status:
Offline
|
|
Originally posted by honeydew:
<STRONG>
I'm not sure how you are using gethostbyname(), but perhaps you could run a similar test using nslookup. If nslookup fails with 'unknown host', then you have a configuration problem. Make sure your search domains are specified in the Network Preferences. Your changes will be reflected in /etc/resolv.conf. If nslookup works and your code does not, check your code for possible bugs.
To continue your example, if your full hostname is 'my-cable-modem-name.my-cable-provider.com', then make sure 'my-cable-provider.com' is listed in the search domains. You can use the following link to find your full hostname:
</STRONG>
Thanks for the tips. My cable provider was listed in resolv.conf. I rolled the dice and fired up NetInfo Manager. I duplicated my -DHCP- setting, but substituted my cable "hostname" and ip number. I then ran the software and it worked.
Since I left the original -DHCP- option and the new item, I wonder if I will run into any dhcp problems in the future.
Scott
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
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
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|