Re: gethostname() and gethostbyname() APIs
Re: gethostname() and gethostbyname() APIs
- Subject: Re: gethostname() and gethostbyname() APIs
- From: Allan Nathanson <email@hidden>
- Date: Tue, 4 May 2004 08:51:08 -0400
As has been discussed on this mailing list MANY times, the name
returned by gethostname(3) may have no relation to an internet host
name that could be looked up using gethostbyname(3). We "try" to set
the name to something reasonable but there's no guarantee that the name
will work in the code snippet you provided.
What are you trying to do?
Are you aware that a host can have multiple IP addresses?
Are you aware that an IP address can have multiple host names
associated with each address?
- Allan
On May 4, 2004, at 1:53 AM, Navin Sharma wrote:
I do not deny that application may have some problem. But, have a
query that
why the two APIs are behaving properly in Panther Client and not in
Panther
Server.
Below is the code chunk:
******************************************************
hostent *hstruct;
in_addr *inaddr;
err = gethostname(name,255);
hstruct = gethostbyname(name);
if(hstruct){
inaddr = (in_addr *) hstruct->h_addr;
}
strcpy(address, (const char *) inet_ntoa(*inaddr));
******************************************************
Runs fine on Panther Client (10.3.3) and not on Panther Server
(10.3.3). Am
I doing some OS specific thing?
Thanks in advance.
Regards
Navin Sharma
_______________________________________________
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.