#include
//#include
#include
void getHostName()
{
struct hostent *myhost;
char ** pp;
struct in_addr addr;
myhost = gethostbyname("www.linuxdiyf.com");
printf("host name is %s\n",myhost->h_name);
// pp = myhost->h_aliases;
// while(*pp!=NULL)
// {
// printf("%s\n",*pp);
// pp++;
// }
for (pp = myhost->h_aliases;*pp!=NULL;pp++)
printf("%02X is %s\n",*pp,*pp);
pp = myhost->h_addr_list;
while(*pp!=NULL)
{
addr.s_addr = *((unsigned int *)*pp);
printf("address is %s\n",inet_ntoa(addr));
pp++;
}
}
结果:
host name is cachesh1.a.linuxdiyf.com
6B1508 is www.linuxdiyf.com
6B1518 is d7.a.linuxdiyf.com
address is 61.152.234.72
address is 61.152.234.73
address is 61.152.234.75
address is 61.152.234.76
address is 61.152.234.77
address is 61.152.234.71
190.37.43.* 于 2007-07-06 00:44:53发表:
http://1cc4966feffef88e2bf808a30f2fe846-t.lwgmrw.org 1cc4966feffef88e2bf808a30f2fe846 http://1cc4966feffef88e2bf808a30f2fe846-b1.lwgmrw.org 1cc4966feffef88e2bf808a30f2fe846 http://1cc4966feffef88e2bf808a30f2fe846-b3.lwgmrw.org 7323937625928ec2c2b389a5c949efe8