gethostbyname返回错误Operation not permitted解决办法
Operation not permitted
__NULL__gethostbyname_h_errno=1
DNS 一般在 /etc/resolv.conf 里面
nameserver 202.101.224.69
nameserver 202.101.226.68
void ParseDomainName2IPAdress(char *pszDomainName, char *pszIP)
{
int iret;
//hostent *ptrHost = NULL;
struct hostent *ptrHost = NULL;
char *ptrIPAdress = NULL;
if (NULL == pszDomainName ||
NULL == pszIP)
return;
ptrHost = gethostbyname(pszDomainName);
if(NULL != ptrHost)
{
COM_TRACE("gethostbyname!=NULL");
ptrIPAdress = inet_ntoa (*(struct in_addr *)*ptrHost->h_addr_list);
strcpy(pszIP, ptrIPAdress);
}
else
{
char * mesg = strerror(h_errno);
printf("Mesg:%s\n",mesg);
COM_TRACE("__NULL__");
COM_TRACE("gethostbyname_h_errno=%d",h_errno);
strcpy(pszIP, pszDomainName);
}
}