Exemple #1
0
 public void BroadcastPacket(Packet packet)
 {
     foreach (var iface in NetworkInterface.GetAllNetworkInterfaces())
     {
         if (iface.NetworkInterfaceType == NetworkInterfaceType.Loopback)
         {
             continue;
         }
         if (iface.OperationalStatus != OperationalStatus.Up)
         {
             continue;
         }
         foreach (var ipAddr in iface.GetIPProperties().UnicastAddresses)
         {
             if (ipAddr.Address.GetAddressBytes().Length != 4)
             {
                 continue;
             }
             SendPacket(NetUtil.CalculateBroadcastAddress(ipAddr.Address, ipAddr.IPv4Mask), packet);
         }
     }
 }