private void SetMulticastOption(SocketOptionName optionName, MulticastOption mr) { IPMulticastRequest mreq = new IPMulticastRequest(); mreq.MulticastAddress = GetIP4Address(mr.Group); if (mr.LocalAddress != null) { mreq.InterfaceAddress = GetIP4Address(mr.LocalAddress); } else { int num = IPAddress.HostToNetworkOrder(mr.InterfaceIndex); mreq.InterfaceAddress = num; } if (UnsafeMethods.setsockopt(Handle, SocketOptionLevel.IPv6, optionName, ref mreq, IPv6MulticastRequest.Size) == SocketError.SocketError) { throw new SocketException(); } }
public static extern SocketError getsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, out IPMulticastRequest optionValue, [In, Out] ref int optionLength);
public static extern SocketError setsockopt([In] IntPtr socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref IPMulticastRequest mreq, [In] int optionLength);