for(int i=0;i<3;i++) {
printf("ping %s..%d\n",inet_ntoa(to.sin_addr),i+1);
FillPackage(buf,dstIP,(u_short)pid);//组装icmp包
if((sock,buf,PACKAGE_SIZE,0,(struct sockaddr *)&to,len) == SOCKET_ERROR)
break;
(&from,0,sizeof(from));
len = sizeof(from);
if( recvfrom(sock,buf,PACKAGE_SIZE,0,(struct sockaddr *)&from,&len) == SOCKET_ERROR)
break;
IPHeader *pIPHdr = (IPHeader *)buf;
ICMPHeader *pICMPHdr = (ICMPHeader *)(buf+sizeof(IPHeader));
if(pICMPHdr->id == htons((u_short)pid) && pICMPHdr->seq == htons((u_short)pid) && pICMPHdr->type == ICMP_ECHO_REPLY) {
printf("Echo Reply From %s,\n",inet_ntoa(.sin_addr));
}
}
Winsock函数中,调用( )函数来链接动态链接库。
A、ws232 B、socket C、WSAStartup D、recv
以下Winsock I/O模型中,哪个是目前为止Win32平台下效率最高的多线程网络编程模型?( )
A、I/O复用 B、I/O完成端口 C、消息机制 D、事件机制