BOOL CheckHostStatus(CString &strIPAddr)
{
//初始化套接字
m_hSocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
//
// Create the ICMP packet
//
// 构造icmp报文
icmp_data =(char*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,MAX_PACKET);
recvbuf =(char*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,MAX_PACKET);
//重要函数,填充ICMP包头
FillICMPData(icmp_data,datasize);
ret = sendto(m_hSocket, icmp_data, datasize, 0,
(struct sockaddr*)&m_addrDest, sizeof(m_addrDest));
int fromlen = sizeof(m_addrFrom);
time= GetTickCount();
ret = recvfrom(m_hSocket, recvbuf, MAX_PACKET, 0,
(struct sockaddr*)&m_addrFrom, &fromlen);
return TRUE;
}