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();
    }
}

.NET Framework
Available since 2.0
Return to top
Show: