Re: Gethostname returns incomplete name
site_archiver@lists.apple.com Delivered-To: macnetworkprog@lists.apple.com Thread-index: Acsd81fzr003iGtHc0mdQU9ps+ORAw== Thread-topic: Gethostname returns incomplete name User-agent: Microsoft-Entourage/12.20.0.090605 We use it for multicast to discover Retrospect clients. And here's the thing, when I run Retrospect 8.1 (shipping), it properly resolves the name but in 8.2 (beta), it does not on some powerpc systems. I can switch between these versions and 8.1 works, 8.2 doesn't. There is clearly something else at work here and I think my best bet is to install a debug version on the affected system. It may be that gethostbyname is failing on it as well but we have another code path for getting the ip address that has broken. Thanks very much on the insight on these two calls. Your right, gethostname doesn't do what I thought it did. I will look into getifaddrs and into what broke between versions. Thanks again, Laurie On 7/6/10 10:11 PM, "Josh Graessley" <jgraessley@apple.com> wrote:
gethostname doesn't really do what you may think it does. It is not guaranteed to return a name that can be resolved using gethostbyname. Some of the time, that does work, but it's just by chance.
You may be looking for getifaddrs, but it's hard to know without knowing what you're actually trying to accomplish.
-josh
On Jul 6, 2010, at 10:07 PM, Laurie Gill wrote:
The following code snippet seems to work on intel but I get mixed results on powerpc. Gethostname always returns noErr but sometimes the name I get back doesn't work in gethostbyname. Result: Host is nil and h_errno is 1.
char hostnamebuf[256]; struct hostent *host;
if ((err = gethostname(hostnamebuf, sizeof(hostnamebuf))) == 0) host = gethostbyname(hostnamebuf);
Example: The name I get is "plechatovm2k3-0" The name I should get is "plechatovm2k3-0.lss.corp.com". This one works when I hard code it.
Any ideas?
Thanks Laurie Gill Roxio Retrospect Sonic Solutions
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (Macnetworkprog@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/macnetworkprog/jgraessley%40apple.com
This email sent to jgraessley@apple.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (Macnetworkprog@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/macnetworkprog/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com
participants (1)
-
Laurie Gill