我用下面代码发送ARP 数据包,等待的时间越短越容易重起机器,超过1000毫秒就不再重起,why????while(1)
{
if(PacketSendPacket(lpAdapter, lpPacket, TRUE)==FALSE) 
{
printf("Error sending the packets!\n");
return 0;
}
Sleep(500);// 时间越短越容易重起机器,超过1000毫秒就不再重起
}

解决方案 »

  1.   

    那为什么用SOCKET的send发送数据包的时候,设为1毫秒就行了呢?
      

  2.   

    使用winpcap要注意缓冲区的问题
      

  3.   

    更正问题:
       是循环发了255个ARP包后机器重起,各位大虾有没有高招???
      

  4.   

    //i think you test this
    if(PacketSetNumWrites(pAdapter,255)==FALSE)
    {
    AfxMessageBox("warning: Unable to send more than one packet in a single write!\n");
    }
    if(PacketSendPacket(pAdapter,pPacket,TRUE)==FALSE)
    {
             AfxMessageBox("Error sending the packets!\n");
    return ;
    }
      

  5.   

    我是这样写的:
    if(PacketSetNumWrites(pAdapter,2)==FALSE)
    {
    AfxMessageBox("warning: Unable to send more than one packet in a single write!\n");
    }
    while(1)
    {
    if(PacketSendPacket(lpAdapter, lpPacket, TRUE)==FALSE) 
    {
    printf("Error sending the packets!\n");
    return 0;
    }
    Sleep(500);
    }先设为发2个,然后循环发,是不是没个PacketSendPacket(lpAdapter, lpPacket, TRUE)都是发了2个???
      

  6.   

    BOOLEAN PacketSendPacket(LPADAPTER AdapterObject, LPPACKET pPacket, BOOLEAN Sync)
    This function is used to send a raw packet to the network through the adapter specified with the AdapterObject parameter. 'Raw packet' means that the programmer will have to build the various headers because the packet is sent to the network 'as is'. The user will not have to put a bpf_hdr header before the packet. Either the CRC needs not to be calculated and added to the packet, because it is transparently put after the end of the data portion by the network interface.This function has the same syntax of PacketReceivePacket.The behavior of this function is influenced by the PacketSetNumWrites function. With PacketSetNumWrites, it is possible to set the number of times a single write must be repeated. If this number is 1, every PacketSendPacket call will correspond to one packet sent to the network. If this number is greater than 1, for example 1000, every raw packet written by the application on the driver's device file will be sent 1000 times on the network. This feature can be used to generate high speed traffic because the overhead of the context switches is no longer present and it is particularly useful to write tools to test networks, routers, and servers. Notice that the ability to write multiple packets is present at the moment only in the Windows NT and Windows 2000 versions of the packet driver. In Windows 95/98/ME it is emulated at user level in PACKET.DLL. This means that an application that uses the 'repeated' write method will run in Windows 9x as well, but its speed will be very low compared to the one of WindowsNTx.The optimized sending process is still limited to one packet at a time: for the moment it cannot be used to send a buffer with multiple packets.
      

  7.   

    cao,我都结贴了,怎么还再这???