• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Sockets.IPv6MulticastOption类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.Sockets.IPv6MulticastOption的典型用法代码示例。如果您正苦于以下问题:C# IPv6MulticastOption类的具体用法?C# IPv6MulticastOption怎么用?C# IPv6MulticastOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IPv6MulticastOption类属于System.Net.Sockets命名空间,在下文中一共展示了IPv6MulticastOption类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Constructor1

		[Test] // .ctor (IPAddress)
		public void Constructor1 ()
		{
			IPv6MulticastOption option;
			IPAddress group;

			group = IPAddress.Parse ("ff02::1");
			option = new IPv6MulticastOption (group);
			Assert.AreSame (group, option.Group, "#A:Group");
			Assert.AreEqual (0, option.InterfaceIndex, "#A:InterfaceIndex");

			group = IPAddress.Parse ("224.0.0.23");
			option = new IPv6MulticastOption (group);
			Assert.AreSame (group, option.Group, "#B:Group");
			Assert.AreEqual (0, option.InterfaceIndex, "#B:InterfaceIndex");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:IPv6MulticastOptionTest.cs


示例2: Constructor2

		[Test] // .ctor (IPAddress, Int64)
		public void Constructor2 ()
		{
			IPv6MulticastOption option;
			IPAddress group;
			long interfaceIndex;

			group = IPAddress.Parse ("239.255.255.250");
			interfaceIndex = 0;
			option = new IPv6MulticastOption (group, interfaceIndex);
			Assert.AreSame (group, option.Group, "#A:Group");
			Assert.AreEqual (interfaceIndex, option.InterfaceIndex, "#A:InterfaceIndex");

			group = IPAddress.Parse ("ff02::1");
			interfaceIndex = 0;
			option = new IPv6MulticastOption (group, interfaceIndex);
			Assert.AreSame (group, option.Group, "#B:Group");
			Assert.AreEqual (interfaceIndex, option.InterfaceIndex, "#B:InterfaceIndex");

			group = IPAddress.Parse ("239.255.255.250");
			interfaceIndex = 124;
			option = new IPv6MulticastOption (group, interfaceIndex);
			Assert.AreSame (group, option.Group, "#C:Group");
			Assert.AreEqual (interfaceIndex, option.InterfaceIndex, "#C:InterfaceIndex");

			group = IPAddress.Parse ("ff02::1");
			interfaceIndex = 124;
			option = new IPv6MulticastOption (group, interfaceIndex);
			Assert.AreSame (group, option.Group, "#D:Group");
			Assert.AreEqual (interfaceIndex, option.InterfaceIndex, "#D:InterfaceIndex");

			group = IPAddress.Parse ("239.255.255.250");
			interfaceIndex = 0xFFFFFFFF;
			option = new IPv6MulticastOption (group, interfaceIndex);
			Assert.AreSame (group, option.Group, "#E:Group");
			Assert.AreEqual (interfaceIndex, option.InterfaceIndex, "#E:InterfaceIndex");

			group = IPAddress.Parse ("ff02::1");
			interfaceIndex = 0xFFFFFFFF;
			option = new IPv6MulticastOption (group, interfaceIndex);
			Assert.AreSame (group, option.Group, "#F:Group");
			Assert.AreEqual (interfaceIndex, option.InterfaceIndex, "#F:InterfaceIndex");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:43,代码来源:IPv6MulticastOptionTest.cs


示例3: InterfaceIndex_Value_OutOfRange

		public void InterfaceIndex_Value_OutOfRange ()
		{
			IPAddress group = IPAddress.Parse ("239.255.255.250");
			IPv6MulticastOption option = new IPv6MulticastOption (group, 10);

			try {
				option.InterfaceIndex = -1;
				Assert.Fail ("#A1");
			} catch (ArgumentOutOfRangeException ex) {
				// Specified argument was out of the range of valid values
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#A2");
				Assert.IsNull (ex.InnerException, "#A3");
				Assert.IsNotNull (ex.Message, "#A4");
				Assert.AreEqual ("value", ex.ParamName, "#A5");
			}

			try {
				option.InterfaceIndex = 0x100000000;
				Assert.Fail ("#B1");
			} catch (ArgumentOutOfRangeException ex) {
				// Specified argument was out of the range of valid values
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#B2");
				Assert.IsNull (ex.InnerException, "#B3");
				Assert.IsNotNull (ex.Message, "#B4");
				Assert.AreEqual ("value", ex.ParamName, "#B5");
			}

			// ensure original value was retained
			Assert.AreEqual (10, option.InterfaceIndex, "#C");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:IPv6MulticastOptionTest.cs


示例4: SetSocketOption

		[Test] // SetSocketOption (SocketOptionLevel, SocketOptionName, Object)
		public void SetSocketOption3_DropMembershipIPv6_IPv6MulticastOption ()
		{
			if (!Socket.OSSupportsIPv6)
				Assert.Ignore ("IPv6 not enabled.");

			using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) {
				IPv6MulticastOption option = new IPv6MulticastOption (
					IPAddress.Parse ("ff02::1"));

				s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
				s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
					option);
				s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.DropMembership,
					option);
			}
		}
开发者ID:Therzok,项目名称:mono,代码行数:17,代码来源:SocketTest.cs


示例5: ReleaseSocket


//.........这里部分代码省略.........

        //            if (externalInterface == null)
        //            {
        //                // Pri3: Do something more helpful here
        //                throw new Exception(Strings.UnableToFindLocalRoutingInterface);
        //            }

        //            if (Utility.IsMulticast(endPoint.Address))
        //            {
        //                // Allow multiple binds to this socket, as it will still function properly
        //                //  (this is only the case if it is a multicast socket.  Unicast sockets fail to
        //                //   receive all data on all sockets)
        //                sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, -1);

        //                // We don't join the multicast group here, because we may not want to listen
        //                // to our own data (halfing our throughput).  jasonv - 10/28/2004
        //            }

        //            // Add the socket to the hashtable
        //            SockInterfacePair sip = new SockInterfacePair(sock, externalInterface);
        //            socks.Add(endPoint, sip);

        //            // Increase the socket's reference count
        //            ++sock.refCount;

        //            return sip;
        //        }
        //    }
        //}

        //internal static void ReleaseSharedSocket(IPEndPoint endPoint, UdpSocket sock)
        //{
        //    object sockObj = socks[endPoint];
        //    if (sockObj == null)
        //        throw new InvalidOperationException(Strings.SockDoesNotExistAsASharedSocket);

        //    lock (socks)
        //    {
        //        if (--sock.refCount <= 0)
        //        {
        //            // Leave the multicast group
        //            if (Utility.IsMulticast(endPoint.Address))
        //            {
        //                try
        //                {
        //                    if (endPoint.AddressFamily == AddressFamily.InterNetworkV6)
        //                    {
        //                        IPv6MulticastOption mo = new IPv6MulticastOption(endPoint.Address);
        //                        sock.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.DropMembership, mo);
        //                    }
        //                    else
        //                    {
        //                        MulticastOption mo = new MulticastOption(endPoint.Address);
        //                        sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, mo);
        //                    }
        //                }
        //                catch { } // The user of the socket *may* not have joined the multicast group (?)
        //            }

        //            // Remove ourselves from the shared pool
        //            socks.Remove(endPoint);

        //            // Close the socket
        //            try
        //            {
        //                sock.Close();
        //            }
        //            catch (ObjectDisposedException) { }
        //        }
        //    }
        //}

        internal static void ReleaseSocket(IPEndPoint endPoint, UdpSocket sock)
        {
            // Leave the multicast group
            if (Utility.IsMulticast(endPoint.Address))
            {
                try
                {
                    if (endPoint.AddressFamily == AddressFamily.InterNetworkV6)
                    {
                        IPv6MulticastOption mo = new IPv6MulticastOption(endPoint.Address);
                        sock.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.DropMembership, mo);
                    }
                    else
                    {
                        MulticastOption mo = new MulticastOption(endPoint.Address);
                        sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, mo);
                    }
                }
                catch { } // The user of the socket *may* not have joined the multicast group (?)
            }

            // Close the socket
            try
            {
                sock.Close();
            }
            catch (ObjectDisposedException) { }
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:101,代码来源:UdpSocket.cs


示例6: SetIPv6MulticastOption

        public static unsafe SocketError SetIPv6MulticastOption(SafeCloseSocket handle, SocketOptionName optionName, IPv6MulticastOption optionValue)
        {
            Debug.Assert(optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership);

            Interop.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
                Interop.Sys.MulticastOption.MULTICAST_ADD :
                Interop.Sys.MulticastOption.MULTICAST_DROP;

            var opt = new Interop.Sys.IPv6MulticastOption {
                Address = optionValue.Group.GetNativeIPAddress(),
                InterfaceIndex = (int)optionValue.InterfaceIndex
            };

            Interop.Error err = Interop.Sys.SetIPv6MulticastOption(handle.FileDescriptor, optName, &opt);
            return err == Interop.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
        }
开发者ID:jemmy655,项目名称:corefx,代码行数:16,代码来源:SocketPal.Unix.cs


示例7: SetIPv6MulticastOption

        public static unsafe SocketError SetIPv6MulticastOption(SafeCloseSocket handle, SocketOptionName optionName, IPv6MulticastOption optionValue)
        {
            int optLevel, optName;
            GetPlatformOptionInfo(SocketOptionLevel.IPv6, optionName, out optLevel, out optName);

            var mreq = new Interop.libc.ipv6_mreq {
                // TODO: what is the endianness of ipv6mr_ifindex?
                ipv6mr_ifindex = checked((int)optionValue.InterfaceIndex)
            };

            byte[] multicastAddress = optionValue.Group.GetAddressBytes();
            Debug.Assert(multicastAddress.Length == sizeof(Interop.libc.in6_addr));

            for (int i = 0; i < multicastAddress.Length; i++)
            {
                mreq.ipv6mr_multiaddr.s6_addr[i] = multicastAddress[i];
            }

            int err = Interop.libc.setsockopt(handle.FileDescriptor, optLevel, optName, &mreq, (uint)sizeof(Interop.libc.ipv6_mreq));
            return err == -1 ? GetLastSocketError() : SocketError.Success;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:21,代码来源:SocketPal.Unix.cs


示例8: setIPv6MulticastOption

        /// <devdoc>
        ///     <para>
        ///         IPv6 setsockopt for JOIN / LEAVE multicast group
        ///     </para>
        /// </devdoc>
        private void setIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR) {
            IPv6MulticastRequest ipmr = new IPv6MulticastRequest();

            ipmr.MulticastAddress = MR.Group.GetAddressBytes();
            ipmr.InterfaceIndex   = unchecked((int)MR.InterfaceIndex);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setIPv6MulticastOption(): optionName:" + optionName.ToString() + " MR:" + MR.ToString() + " ipmr:" + ipmr.ToString() + " IPv6MulticastRequest.Size:" + IPv6MulticastRequest.Size.ToString());

            // This can throw ObjectDisposedException.
            SocketError errorCode = UnsafeNclNativeMethods.OSSOCK.setsockopt(
                m_Handle,
                SocketOptionLevel.IPv6,
                optionName,
                ref ipmr,
                IPv6MulticastRequest.Size);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setIPv6MulticastOption() UnsafeNclNativeMethods.OSSOCK.setsockopt returns errorCode:" + errorCode);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "setIPv6MulticastOption", socketException);
                throw socketException;
            }
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:36,代码来源:Socket.cs


示例9: ProcessJoinRequest

        private static RegisterMessage ProcessJoinRequest(RegisterMessage joinRequestMessage, IPAddress senderIP)
        {
            try
            {
                // If the senderIP already exists, remove it by following the rule - the last one wins
                if (clientRegTable.ContainsKey(senderIP))
                {
                    lock (clientRegTable.SyncRoot)
                    {
                        clientRegTable.Remove(senderIP);
                    }
                }

                // Insert the new entry
                Random rnd = new Random();
                int confirmNumber = rnd.Next(1, Int32.MaxValue);

                lock (clientRegTable.SyncRoot)
                {
                    clientRegTable.Add(senderIP, new ClientEntry(senderIP, new IPEndPoint(joinRequestMessage.groupIP,
                        joinRequestMessage.groupPort), DateTime.Now, confirmNumber, DateTime.Now));

                    ReflectorMgr.PC[ReflectorPC.ID.TotalParticipants]++;
                    ReflectorMgr.PC[ReflectorPC.ID.CurrentParticipats] = clientRegTable.Count;
                }

                joinRequestMessage.msgType = MessageType.Confirm;
                joinRequestMessage.confirmNumber = confirmNumber;
                joinRequestMessage.unicastPort = ReflectorMgr.ReflectorUnicastRTPListenPort;

                if (joinRequestMessage.groupIP.AddressFamily == AddressFamily.InterNetwork)
                {
                    MulticastOption mo = new MulticastOption(joinRequestMessage.groupIP,ReflectorMgr.MulticastInterfaceIP);
                    ReflectorMgr.Sockets.SockMCv4RTP.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mo);
                    ReflectorMgr.Sockets.SockMCv4RTCP.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mo);
                }
                else
                {
                    IPv6MulticastOption mo = new IPv6MulticastOption(joinRequestMessage.groupIP);
                    ReflectorMgr.Sockets.SockMCv6RTP.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, mo);
                    ReflectorMgr.Sockets.SockMCv6RTCP.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, mo);
                }
            }

            catch
            {
                joinRequestMessage.msgType = MessageType.UnknownError;
            }

            return joinRequestMessage;
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:51,代码来源:RegistrarServer.cs


示例10: SetIPv6MulticastOption

        private void SetIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption mr)
        {
            var optionValue = new IPv6MulticastRequest()
            {
                MulticastAddress = mr.Group.GetAddressBytes(),
                InterfaceIndex = (int)mr.InterfaceIndex
            };

            if (UnsafeMethods.setsockopt(Handle, SocketOptionLevel.IPv6, optionName, ref optionValue, IPv6MulticastRequest.Size) ==
                SocketError.SocketError)
            {
                throw new SocketException();
            }
        }
开发者ID:songfj,项目名称:AsyncIO,代码行数:14,代码来源:Socket.cs


示例11: JoinMulticastGroup

        ///     <devdoc>
        ///         <para>
        ///             Joins an IPv6 multicast address group.
        ///         </para>
        ///     </devdoc>
        public void JoinMulticastGroup(int ifindex,IPAddress multicastAddr) {
            //
            // parameter validation
            //
            if ( m_CleanedUp ){
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            if ( multicastAddr==null ) {
                throw new ArgumentNullException("multicastAddr");
            }

            if ( ifindex < 0 ) {
                throw new ArgumentException(SR.GetString(SR.net_value_cannot_be_negative), "ifindex");
            }

            //
            // Ensure that this is an IPv6 client, otherwise throw WinSock 
            // Operation not supported socked exception.
            //
            if ( m_Family != AddressFamily.InterNetworkV6 ) {
                throw new SocketException(SocketError.OperationNotSupported);
            }

            IPv6MulticastOption mcOpt = new IPv6MulticastOption(multicastAddr,ifindex);

            Client.SetSocketOption(
                SocketOptionLevel.IPv6,
                SocketOptionName.AddMembership,
                mcOpt );
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:36,代码来源:udpclient.cs


示例12: setIPv6MulticastOption

 private void setIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR)
 {
     if (UnsafeNclNativeMethods.OSSOCK.setsockopt(this.m_Handle, SocketOptionLevel.IPv6, optionName, ref new IPv6MulticastRequest()
       {
     MulticastAddress = MR.Group.GetAddressBytes(),
     InterfaceIndex = (int) MR.InterfaceIndex
       }, IPv6MulticastRequest.Size) != SocketError.SocketError)
     return;
       SocketException socketException = new SocketException();
       this.UpdateStatusAfterSocketError(socketException);
       if (Socket.s_LoggingEnabled)
     Logging.Exception(Logging.Sockets, (object) this, "setIPv6MulticastOption", (Exception) socketException);
       throw socketException;
 }
开发者ID:korifey,项目名称:hackathon-Ideaphone,代码行数:14,代码来源:Socket.cs


示例13: SetIPv6MulticastOption

        // IPv6 setsockopt for JOIN / LEAVE multicast group.
        private void SetIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR)
        {
            SocketError errorCode = SocketPal.SetIPv6MulticastOption(_handle, optionName, MR);

            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Interop.Winsock.setsockopt returns errorCode:{errorCode}");

            // Throw an appropriate SocketException if the native call fails.
            if (errorCode != SocketError.Success)
            {
                // Update the internal state of this socket according to the error before throwing.
                SocketException socketException = new SocketException((int)errorCode);
                UpdateStatusAfterSocketError(socketException);
                if (NetEventSource.IsEnabled) NetEventSource.Error(this, socketException);
                throw socketException;
            }
        }
开发者ID:AtsushiKan,项目名称:corefx,代码行数:17,代码来源:Socket.cs


示例14: DropMulticastGroup

        // Leaves a multicast address group.
        public void DropMulticastGroup(IPAddress multicastAddr)
        {
            // Validate input parameters.
            if (_cleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            if (multicastAddr == null)
            {
                throw new ArgumentNullException("multicastAddr");
            }

            // IPv6 Changes: we need to create the correct MulticastOption and
            //               must also check for address family compatibility.
            if (multicastAddr.AddressFamily != _family)
            {
                throw new ArgumentException(SR.Format(SR.net_protocol_invalid_multicast_family, "UDP"), "multicastAddr");
            }

            if (_family == AddressFamily.InterNetwork)
            {
                MulticastOption mcOpt = new MulticastOption(multicastAddr);

                _clientSocket.SetSocketOption(
                    SocketOptionLevel.IP,
                    SocketOptionName.DropMembership,
                    mcOpt);
            }
            else
            {
                IPv6MulticastOption mcOpt = new IPv6MulticastOption(multicastAddr);

                _clientSocket.SetSocketOption(
                    SocketOptionLevel.IPv6,
                    SocketOptionName.DropMembership,
                    mcOpt);
            }
        }
开发者ID:nbilling,项目名称:corefx,代码行数:39,代码来源:UDPClient.cs


示例15: DropMulticastGroup

        public void DropMulticastGroup(IPAddress address)
        {
            Assert.AreEqual(address.AddressFamily, this.LocalEp.AddressFamily, "address.AddressFamily");

            if (this.LocalEp.AddressFamily == AddressFamily.InterNetwork)
            {
                var option1 = new MulticastOption(address);
                this._client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, option1);
            }
            else
            {
                var option2 = new IPv6MulticastOption(address);
                this._client.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.DropMembership, option2);
            }
        }
开发者ID:kthompson,项目名称:RtpLib,代码行数:15,代码来源:UdpListener.cs


示例16: JoinMulticastGroup

        public void JoinMulticastGroup(IPAddress address, int ttl)
        {
            Assert.AreEqual(address.AddressFamily, this.LocalEp.AddressFamily, "address.AddressFamily");
            Assert.That(this.IsStarted, () => new InvalidOperationException("UdpListener must be started to join multicast group"));

            switch (this.LocalEp.AddressFamily)
            {
                case AddressFamily.InterNetwork:
                    var option1 = new MulticastOption(address, this.LocalEp.Address);
                    this._client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, option1);
                    this._client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, ttl);
                    break;
                case AddressFamily.InterNetworkV6:
                    //FIXME: this should be using the interface index of the interface we are bound to.
                    var option2 = new IPv6MulticastOption(address);
                    this._client.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, option2);
                    this._client.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.MulticastTimeToLive, ttl);
                    break;
                default:
                    Assert.That(false, () => new NotSupportedException("UdpListener only supports IPv4 and IPv6."));
                    break;
            }
        }
开发者ID:kthompson,项目名称:RtpLib,代码行数:23,代码来源:UdpListener.cs


示例17: ProcessLeaveRequest

        private static RegisterMessage ProcessLeaveRequest(RegisterMessage leaveRequestMessage, IPAddress senderIP)
        {
            try
            {
                lock (clientRegTable.SyncRoot)
                {
                    if (clientRegTable.ContainsKey(senderIP))
                    {
                        bool drop = true;
                        clientRegTable.Remove(senderIP);
                        ReflectorMgr.PC[ReflectorPC.ID.CurrentParticipats] = clientRegTable.Count;

                        // Drop membership if no other member exists
                        foreach (ClientEntry entry in clientRegTable.Values)
                        {
                            if (entry.GroupEP.Address.Equals(leaveRequestMessage.groupIP))
                            {
                                drop = false;
                                break;
                            }
                        }

                        if (drop)
                        {
                            if (leaveRequestMessage.groupIP.AddressFamily == AddressFamily.InterNetwork)
                            {
                                MulticastOption mo = new MulticastOption(leaveRequestMessage.groupIP,ReflectorMgr.MulticastInterfaceIP);
                                ReflectorMgr.Sockets.SockMCv4RTP.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, mo);
                                ReflectorMgr.Sockets.SockMCv4RTCP.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, mo);
                            }
                            else
                            {
                                IPv6MulticastOption mo = new IPv6MulticastOption(leaveRequestMessage.groupIP);
                                ReflectorMgr.Sockets.SockMCv6RTP.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.DropMembership, mo);
                                ReflectorMgr.Sockets.SockMCv6RTCP.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.DropMembership, mo);
                            }
                        }

                        return new RegisterMessage(MessageType.Confirm, leaveRequestMessage.groupIP, leaveRequestMessage.groupPort, leaveRequestMessage.confirmNumber);
                    }
                    else
                    {   // No entries found for the leave request
                        return new RegisterMessage(MessageType.LeaveWithoutJoinError, IPAddress.Any);
                    }
                }
            }

            catch
            {
                return new RegisterMessage(MessageType.UnknownError, IPAddress.Any);
            }
        }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:52,代码来源:RegistrarServer.cs


示例18: getIPv6MulticastOpt

        /// <devdoc>
        ///     <para>
        ///         IPv6 getsockopt for JOIN / LEAVE multicast group
        ///     </para>
        /// </devdoc>
        private IPv6MulticastOption getIPv6MulticastOpt(SocketOptionName optionName) {
            IPv6MulticastRequest ipmr = new IPv6MulticastRequest();

            int optlen = IPv6MulticastRequest.Size;

            // This can throw ObjectDisposedException.
            SocketError errorCode = UnsafeNclNativeMethods.OSSOCK.getsockopt(
                m_Handle,
                SocketOptionLevel.IP,
                optionName,
                out ipmr,
                ref optlen);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::getIPv6MulticastOpt() UnsafeNclNativeMethods.OSSOCK.getsockopt returns errorCode:" + errorCode);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "getIPv6MulticastOpt", socketException);
                throw socketException;
            }

            IPv6MulticastOption multicastOption = new IPv6MulticastOption(new IPAddress(ipmr.MulticastAddress),ipmr.InterfaceIndex);

            return multicastOption;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:37,代码来源:Socket.cs


示例19: SetIPv6MulticastOption

        public static SocketError SetIPv6MulticastOption(SafeCloseSocket handle, SocketOptionName optionName, IPv6MulticastOption optionValue)
        {
            Interop.Winsock.IPv6MulticastRequest ipmr = new Interop.Winsock.IPv6MulticastRequest();

            ipmr.MulticastAddress = optionValue.Group.GetAddressBytes();
            ipmr.InterfaceIndex = unchecked((int)optionValue.InterfaceIndex);

            // This can throw ObjectDisposedException.
            SocketError errorCode = Interop.Winsock.setsockopt(
                handle,
                SocketOptionLevel.IPv6,
                optionName,
                ref ipmr,
                Interop.Winsock.IPv6MulticastRequest.Size);
            return errorCode == SocketError.SocketError ? GetLastSocketError() : SocketError.Success;
        }
开发者ID:vbouret,项目名称:corefx,代码行数:16,代码来源:SocketPal.Windows.cs


示例20: GetIPv6MulticastOption

        public static unsafe SocketError GetIPv6MulticastOption(SafeCloseSocket handle, SocketOptionName optionName, out IPv6MulticastOption optionValue)
        {
            int optLevel, optName;
            GetPlatformOptionInfo(SocketOptionLevel.IPv6, optionName, out optLevel, out optName);

            var mreq = new Interop.libc.ipv6_mreq();
            var optLen = (uint)sizeof(Interop.libc.ipv6_mreq);
            int err = Interop.libc.getsockopt(handle.FileDescriptor, optLevel, optName, &mreq, &optLen);
            if (err == -1)
            {
                optionValue = default(IPv6MulticastOption);
                return GetLastSocketError();
            }

            var multicastAddress = new byte[sizeof(Interop.libc.in6_addr)];
            for (int i = 0; i < multicastAddress.Length; i++)
            {
                multicastAddress[i] = mreq.ipv6mr_multiaddr.s6_addr[i];
            }

            optionValue = new IPv6MulticastOption(new IPAddress(multicastAddress), mreq.ipv6mr_ifindex);
            return SocketError.Success;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:23,代码来源:SocketPal.Unix.cs



注:本文中的System.Net.Sockets.IPv6MulticastOption类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Sockets.LingerOption类代码示例发布时间:2022-05-26
下一篇:
C# Sockets.IPPacketInformation类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap