DWORD URLToIPAddr(char *url)
{
DWORD nIpAddr = 0;
if(strlen(url) < 1)
return 0;
nIpAddr = inet_addr(url);
if(INADDR_NONE == nIpAddr)
{
//通过DNS转换为IP地址
struct hostent *host = gethostbyname(url);
if(NULL == host)
return 0;
nIpAddr =*((unsigned long *)host->h_addr_list[0]);
}
return nIpAddr;
}
{
DWORD nIpAddr = 0;
if(strlen(url) < 1)
return 0;
nIpAddr = inet_addr(url);
if(INADDR_NONE == nIpAddr)
{
//通过DNS转换为IP地址
struct hostent *host = gethostbyname(url);
if(NULL == host)
return 0;
nIpAddr =*((unsigned long *)host->h_addr_list[0]);
}
return nIpAddr;
}