Is In Multicast IP Range - CSharp System.Net

CSharp examples for System.Net:IP Address

Description

Is In Multicast IP Range

Demo Code

// Copyright (C) 2003-2005 Microsoft Corporation, All rights reserved.
using System.Globalization;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Net.Sockets;
using System.Net;
using System;// ww w  . j a  va  2  s .c  o m

public class Main{
        internal static bool IsInMulticastRange(IPAddress address)
        {
            if (address.AddressFamily == AddressFamily.InterNetwork)
            {
                // 224.0.0.0 through 239.255.255.255
                byte[] addressBytes = address.GetAddressBytes();
                return ((addressBytes[0] & 0xE0) == 0xE0);
                //(address.Address & MulticastIPAddress.IPv4MulticastMask) == MulticastIPAddress.IPv4MulticastMask);
            }
            else
            {
                return address.IsIPv6Multicast;
            }
        }
}

Related Tutorials