資源簡介
dns域名解析簡單實現,采用c編寫,主要代碼
代碼片段和文件信息
#include??
#include??
#include??
#include??
#include??
#include??
int?main(int?argc?char?**argv)?
{?
struct?sockaddr_in?addr;?
????struct?hostent?*host;?
char?**alias;?
if(argc<2)?
{?
fprintf(stderr“Usage:%s?hostname|ip..\n\a“argv[0]);?
exit(1);?
}?
argv++;?
for(;*argv!=NULL;argv++)?
{?
/*?這里我們假設是IP*/????
if(inet_aton(*argv&addr.sin_addr)!=0)?
{?
host=gethostbyaddr((char???*)&addr.sin_addr4AF_INET);??
printf(“Address?information?of?Ip?%s\n“*argv);?
- 上一篇:pla
yerglobal.swc - 下一篇:B樣條實現代碼
評論
共有 條評論