public void JoinMulticastGroup(IPAddress multicastAddr, int timeToLive)
{
// parameter validation;
if (_cleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
if (multicastAddr == null)
{
throw new ArgumentNullException(nameof(multicastAddr));
}
if (!RangeValidationHelpers.ValidateRange(timeToLive, 0, 255))
{
throw new ArgumentOutOfRangeException(nameof(timeToLive));
}
// Join the Multicast Group.
JoinMulticastGroup(multicastAddr);
// Set Time To Live (TTL).
_clientSocket.SetSocketOption(
(_family == AddressFamily.InterNetwork) ? SocketOptionLevel.IP : SocketOptionLevel.IPv6,
SocketOptionName.MulticastTimeToLive,
timeToLive);
}