日期:2014-05-16 浏览次数:20849 次
//设置套节字选项 if (SOCKET_ERROR == setsockopt(m_RawSock,SOL_SOCKET,SO_REUSEADDR,(char *)&bOptval,sizeof(bOptval))) { return FALSE; } //IP_HDRINCL该选项使之能操作IP头 if (SOCKET_ERROR == setsockopt(m_RawSock,IPPROTO_IP,IP_HDRINCL,(char *)&bOptval,sizeof(bOptval))) { return FALSE; } //设置SOCK_RAW为SIO_RCVALL,以便接收所有的IP包 WSAIoctl (m_RawSock,SIO_RCVALL,&dwBufferInLen,sizeof(dwBufferInLen),&dwBufferLen,sizeof(dwBufferLen),&dwBytesReturned,NULL,NULL);