This documentation is archived and is not being maintained.

IPInterfaceProperties.MulticastAddresses Property

Gets the multicast addresses assigned to this interface.

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

public abstract MulticastIPAddressInformationCollection MulticastAddresses { get; }

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.

public static void DisplayMulticastAddresses()
{
    int count = 0;

    Console.WriteLine("Multicast Addresses");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        MulticastIPAddressInformationCollection multiCast = adapterProperties.MulticastAddresses;
        if (multiCast.Count > 0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddressInformation multi in multiCast)
            {
                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 addressses were found.");
        Console.WriteLine();
    }
}
void DisplayMulticastAddresses()
{
    Console::WriteLine(S"Multicast Addresses");
    NetworkInterface* adapters[]  = NetworkInterface::GetAllNetworkInterfaces();
    System::Collections::IEnumerator* myEnum15 = adapters->GetEnumerator();
    while (myEnum15->MoveNext())
    {
        NetworkInterface* adapter = __try_cast<NetworkInterface*>(myEnum15->Current);
        IPInterfaceProperties* adapterProperties = adapter->GetIPInterfaceProperties();
        IPAddressInformationCollection* multiCast = adapterProperties->MulticastAddresses;
        if (multiCast->Count > 0)
        {
            Console::WriteLine(adapter->Description);
            System::Collections::IEnumerator* myEnum16 = multiCast->GetEnumerator();
            while (myEnum16->MoveNext())
            {
                IPAddressInformation* multi = __try_cast<IPAddressInformation*>(myEnum16->Current);
                Console::WriteLine(S"  Multicast Address ....................... : {0} {1} {2}", 
                    multi->Address,
                    multi->IsTransient ? S"Transient" : S"", 
                    multi->IsDnsEligible ? S"DNS Eligible" : S""
                    );
            }
            Console::WriteLine();
        }
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: