Re: gethostname returns loginname on "Pather Server" version
Re: gethostname returns loginname on "Pather Server" version
- Subject: Re: gethostname returns loginname on "Pather Server" version
- From: Justin Walker <email@hidden>
- Date: Fri, 6 Feb 2004 09:26:59 -0800
On Friday, February 6, 2004, at 02:22 AM, Sanjay Arora wrote:
'hostname' command returns "admin".
Following is the code snippet i am trying.
hinfo = gethostname(name,255);
hinfo2 = gethostbyname(name)
inaddr = (in_addr*)hinfo2->h_addr;
*addr = inaddr->s_addr;
the name returned is "admin" and gethostbyname fails thereafter.
My point about gethostname() is that this value is totally unrelated to
the information provided by gethostbyname(). The former is just some
string. It has no relation to DNS. You should check
getnameinfo/getaddrinfo.
I don't know exactly what is going wrong, but the reason you get
'admin' from 'gethostname()' is that is what the kernel thinks your
hostname is, and the kernel thinks that is the hostname because some
other piece of code ran earlier to 'sethostname()' to "admin". This is
precisely the point that I am making (and Quinn, before me): don't use
'gethostname()'.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | It's not whether you win or
lose...
| It's whether *I* win or lose.
*--------------------------------------*-------------------------------*
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.