微软ping程序源代码完整版
日期:2007年9月5日 作者: 查看:[大字体 中字体 小字体]-
for(int i=0;i{
int bwrote;
((IcmpHeader*)icmp_data)->i_cksum = 0;
((IcmpHeader*)icmp_data)->timestamp = GetTickCount();
((IcmpHeader*)icmp_data)->i_seq = seq_no++;
((IcmpHeader*)icmp_data)->i_cksum = checksum((USHORT*)icmp_data,datasize);
bwrote = sendto(sockRaw,icmp_data,datasize,0,(struct sockaddr*)&dest,sizeof(dest));
if (bwrote == SOCKET_ERROR){
if (WSAGetLastError() == WSAETIMEDOUT) {
printf("Request timed out.\n");
continue;
}
fprintf(stderr,"sendto failed: %d\n",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
if (bwrote < datasize ) {
fprintf(stdout,"Wrote %d bytes\n",bwrote);
}
bread = recvfrom(sockRaw,recvbuf,MAX_PACKET,0,(struct sockaddr*)&from,&fromlen);
if (bread == SOCKET_ERROR){
if (WSAGetLastError() == WSAETIMEDOUT) {
printf("Request timed out.\n");
continue;
}
fprintf(stderr,"recvfrom failed: %d\n",WSAGetLastError());
ExitProcess(STATUS_FAILED);
}
if(!decode_resp(recvbuf,bread,&from))
statistic++; /* 成功接收的数目++ */
Sleep(1000);
}
/*
Display the statistic result
*/
fprintf(stdout,"\nPing statistics for %s \n",dest_ip);
fprintf(stdout," Packets: Sent = %d,Received = %d, Lost = %d (%2.0f%% loss)\n",times,
statistic,(times-statistic),(float)(times-statistic)/times*100);
WSACleanup();
return 0;
}
/*
The response is an IP packet. We must decode the IP header to locate
the ICMP data
*/
int decode_resp(char *buf, int bytes,struct sockaddr_in *from) {
IpHeader *iphdr;
IcmpHeader *icmphdr;
unsigned short iphdrlen;
iphdr = (IpHeader *)buf;
iphdrlen = (iphdr->h_len) * 4 ; // number of 32-bit words *4 = bytes - 上一页 [1] [2] [3] [4] [5] [6] 下一页
-
- 微软ping程序源代码完整版 相关文章:
- ·微软会发布Win Server 2008 RC2?
- ·微软官网Microsoft.com安全防护趣闻
- ·下载:MSN微软官方圣诞表情包
- ·深入了解微软Windows 7系统
- ·微软Live Search地图服务中文版上线
- ·微软推中文版地图Live Search服务
- ·微软问答录 到底WHS是干啥的?
- ·Win XP SP3 RC1微软官方下载
- ·微软发布2007年最后7个安全补丁
- ·微调Vista“用户帐户控制”功能
- 微软ping程序源代码完整版 相关软件
- ·《冰封王座》地图:微雨传奇 1.7
- ·蒙娜丽莎的微笑
- ·《微笑娃娃》解密试玩
- ·手机游戏:动物园大亨(微软正版)
- ·《细致入微的战争铅笔画》
- ·显微镜下的雪花(图集)
- ·微软IE网络霸业十年回眸
- ·俗世奇人(冯骥才微型小说集)
- ·微软Visio绘图工具
- ·微型小说写作讲座
- 特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作
- 者.文章版权归文章原始作者所有.对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转
- 载的文章有版权问题请联系编辑人员,我们尽快予以更正. 转载请注明来源:http://www.hackhome.com
上一篇:从博客说起 网络新模式愚人娱人
精品推荐
热点TOP10
特别推荐
- ·用net start 可以启动的服务命令一览
- ·Linux阅读材料
- ·掌握IP地址知识 子网掩码与子网划分
- ·ADSL共享方案及实例操作
- ·2000/XP中无法删除文件的解决办法
- ·最全面的密码破解以及抗击手段大曝光
- ·两台电脑直连的方法
- ·电子邮件头解析
- ·密码遗忘通关手册
- ·Regsvr32的特殊作用
- ·收藏经典:windows消息大全
- ·nslookup-ipconfig基础网络命令
- ·网络硬盘数据保护及还原精灵实战
- ·巧用net命令进行局域网文件批量同步更新
- ·打造WIN2000/XP/2003系统万能克隆
- ·菜鸟必知 shift键十大密招大公开
- ·快速批量绑定MAC与IP地址
- ·98/2000/XP密码恢复方法
- ·还原精灵之另类破解
- ·查看内存是否处于双通道模式
