I have this code:
struct hostent *host;
struct hostent *serverHost;
if ((host = gethostbyname(param.ipadress)) == NULL)
{
return -1;
}
if ((serverHost = gethostbyname(param.dnsserver)) == NULL)
{
return -1;
}
and now when I tried host->h_addr it contains address from param.dnsserver. What is wrong? What I am doing wrong?
gethostbynameandgethostbyaddrare old functions that should not be used anymore.For their POSIX (2004) description:
Which means you need to copy the parts you want from the return value before a subsequent call.
Additionally:
And indeed, they are no longer in POSIX 2008.
The replacements are: