IPInterfaceProperties::MulticastAddresses Property

 

Gets the multicast addresses assigned to this interface.

Namespace:   System.Net.NetworkInformation
Assembly:  System (in System.dll)

public:
property MulticastIPAddressInformationCollection^ MulticastAddresses {
	virtual MulticastIPAddressInformationCollection^ get() abstract;
}

Property Value

Type: System.Net.NetworkInformation::MulticastIPAddressInformationCollection^

An MulticastIPAddressInformationCollection that contains the multicast addresses for this interface.

A multicast address identifies multiple computers. Packets sent to a multicast address are sent to all computers identified by the address.

The following code example displays the multicast addresses for the network interfaces on the local computer.

void DisplayMulticastAddresses()
{
   int count = 0;

   Console::WriteLine( "Multicast Addresses" );
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum15 = adapters->GetEnumerator();
   while ( myEnum15->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum15->Current);
      IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
      MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses;
      if ( multiCast->Count > 0 )
      {
         Console::WriteLine( adapter->Description );
         System::Collections::IEnumerator^ myEnum16 = multiCast->GetEnumerator();
         while ( myEnum16->MoveNext() )
         {
            MulticastIPAddressInformation ^ multi = safe_cast<MulticastIPAddressInformation ^>(myEnum16->Current);
            Console::WriteLine( "  Multicast Address ....................... : {0} {1} {2}", 
               multi->Address, multi->IsTransient ? "Transient" : "", 
               multi->IsDnsEligible ? "DNS Eligible" : "" );
            count++;   
         }
         Console::WriteLine();
      }
   }
    if (count == 0)
    {
        Console::WriteLine("  No multicast addresses were found.");
        Console::WriteLine();
    }
}

.NET Framework
Available since 2.0
Return to top
Show: