public void JoinMulticastGroup(int ifindex, IPAddress multicastAddr)
{
// Validate input parameters.
if (_cleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
if (multicastAddr == null)
{
throw new ArgumentNullException(nameof(multicastAddr));
}
if (ifindex < 0)
{
throw new ArgumentException(SR.net_value_cannot_be_negative, nameof(ifindex));
}
// Ensure that this is an IPv6 client, otherwise throw WinSock
// Operation not supported socked exception.
if (_family != AddressFamily.InterNetworkV6)
{
throw new SocketException((int)SocketError.OperationNotSupported);
}
IPv6MulticastOption mcOpt = new IPv6MulticastOption(multicastAddr, ifindex);
_clientSocket.SetSocketOption(
SocketOptionLevel.IPv6,
SocketOptionName.AddMembership,
mcOpt);
}