📄 main.cpp
字号:
#include "stdafx.h"
#include "ping.h"
void _tmain(int argc, TCHAR *argv[])
{
if (argc != 2)
{
printf("You must specify who you want to ping on the command line\n");
return;
}
#ifdef CPING_USE_ICMP
{
CPing p1;
CPingReply pr1;
if (p1.Ping1(argv[1], pr1))
{
hostent* phostent = gethostbyaddr((char *)&pr1.Address.S_un.S_addr, 4, PF_INET);
printf("%d.%d.%d.%d [%s], replied in RTT:%dms\n",
pr1.Address.S_un.S_un_b.s_b1, pr1.Address.S_un.S_un_b.s_b2, pr1.Address.S_un.S_un_b.s_b3,
pr1.Address.S_un.S_un_b.s_b4, phostent->h_name, pr1.RTT);
}
else
printf("Failed in call to ping, GetLastError returns: %d", GetLastError());
}
#endif
#ifdef CPING_USE_WINSOCK2
{
CPing p2;
CPingReply pr2;
if (p2.Ping2(argv[1], pr2))
{
hostent* phostent = gethostbyaddr((char *)&pr2.Address.S_un.S_addr, 4, PF_INET);
printf("%d.%d.%d.%d [%s], replied in RTT:%dms\n",
pr2.Address.S_un.S_un_b.s_b1, pr2.Address.S_un.S_un_b.s_b2, pr2.Address.S_un.S_un_b.s_b3,
pr2.Address.S_un.S_un_b.s_b4, phostent->h_name, pr2.RTT);
}
else
printf("Failed in call to ping, GetLastError returns: %d", GetLastError());
}
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -