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
;
}
查看全文
相关阅读:
javascript 阻止多次点击造成的轮播混乱
javascript切换效果
关于bxslider在点击左右按钮之后不能自动切换的问题解决
javascript 多图无缝切换
javascript 多图无缝切换
javascript 切换动画
javascript无缝全屏轮播
jquery css3 手机菜单动画综合版
jquery模仿css3延迟效果
Mysql的存储过程总结
原文地址:https://www.cnblogs.com/frischzenger/p/1584672.html
最新文章
【leetcode❤python】 219. Contains Duplicate II
【leetcode❤python】 223. Rectangle Area
【leetcode❤python】 290. Word Pattern
【leetcode❤python】 19. Remove Nth Node From End of List
【leetcode❤python】 111. Minimum Depth of Binary Tree
【leetcode❤python】 38. Count and Say
第一个helloworld,有点小兴奋
docker中创建容器时文件挂载和端口映射命令与首次登录官方mysql的参数
Docker的启停与配置等
Docker基础命令(安装和创建管理容器)
热门文章
bkce-6.0.4基础环境部署简述
Jetbrains系列产品无限时间重置插件
CICD:持续集成、持续交付、持续部署-基础概念
开放性研究实验:分析存储日志
Django环境的Linux安装(使用put方法将本地安装包导入到Linux)
Docker容器技术基础
Linux下mysql的二进制安装与部分练习
pycharm连接服务器Docker中的Python环境
Docker基础操作
javascript无缝流畅动画轮播,终于让我给搞出来了。
Copyright © 2011-2022 走看看