zoukankan
html css js c++ java
通过域名显示IP列表
#define
__LINUX__
#include
<
stdio.h
>
#ifdef __LINUX__
#include
<
netdb.h
>
#include
<
sys
/
socket.h
>
#else
#include
<
winsock2.h
>
#pragma
comment(lib, "ws2_32.lib")
#endif
int
main(
int
argc,
char
*
argv[])
{
struct
hostent
*
hptr;
char
**
pptr;
char
hostname[
32
];
char
str[
32
];
#ifndef __LINUX__
WSADATA wsa;
WSAStartup(MAKEWORD(
2
,
2
),
&
wsa);
#endif
if
(gethostname(hostname,
sizeof
(hostname)))
{
#ifdef __LINUX__
printf(
"
gethostname calling error: %d \n
"
);
#else
printf(
"
gethostname calling error: %d \n
"
, WSAGetLastError());
#endif
return
1
;
}
printf(
"
localhost name: %s\n
"
, hostname);
strcpy(hostname, argv[
1
]);
if
((hptr
=
gethostbyname(hostname))
==
NULL)
{
printf(
"
gethostbyname calling error\n
"
);
return
1
;
}
int
i
=
0
;
pptr
=
hptr
->
h_addr_list;
for
(;
*
pptr
!=
NULL; pptr
++
)
{
#ifdef __LINUX__
printf(
"
address: %s \n
"
, inet_ntop(hptr
->
h_addrtype,
*
pptr, str,
sizeof
(str)));
#else
printf(
"
address: %s \n
"
, inet_ntoa(
*
( (
struct
in_addr
*
)hptr
->
h_addr_list[i] )));
i
++
;
#endif
}
return
0
;
}
查看全文
相关阅读:
项目支持
PHP wamp 环境配置
事务 锁 高并发下的解决方法
Hybrid开发
Phonegap IOS 篇 -如何用虚拟机发布APP
Visual Studio 切换到设计模式卡死解决方法
批处理基本命令
Phonegap Android篇
jQuery插件——Validation Plugin
PHP PDO学习(二) exec执行SQL
原文地址:https://www.cnblogs.com/frischzenger/p/1584672.html
最新文章
苹果APP发布不要在ipv6下进行
免费SSL证书的OCSP问题
苹果开发者帐号支付问题:支付授权失败
Centos7 Openresty 开发环境
廉价OpenVZ的VPS如何在solusvm下保证永不死
NTFS在openwrt下的挂载问题
lede install unifi controller
harbor客户端证书问题
oracle获取子串
jQuery 通过JS 生成一个自定义下载页面
热门文章
使用 pqgrid 将JSON数据转换成TABLE
elcipse直接使用.class文件
ORA-00932: 数据类型不一致: 应为 -, 但却获得 –
工具应用--chome 离线安装 postman
spring3 中 context:property-placeholder 的应用
oracle-游标循环
JSON 的封装和解析
ORACLE日期时间函数大全
Angular 学习 mac 电脑
Linux 的配置与学习
Copyright © 2011-2022 走看看