當前位置: 首頁>>代碼示例>>C#>>正文


C# SocketBase.SetSocketOption方法代碼示例

本文整理匯總了C#中NetMQ.zmq.SocketBase.SetSocketOption方法的典型用法代碼示例。如果您正苦於以下問題:C# SocketBase.SetSocketOption方法的具體用法?C# SocketBase.SetSocketOption怎麽用?C# SocketBase.SetSocketOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NetMQ.zmq.SocketBase的用法示例。


在下文中一共展示了SocketBase.SetSocketOption方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetSocketOption

        public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
        {
            if (s == null || !s.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            s.SetSocketOption(option, optval);
        }
開發者ID:kamlesh-patel,項目名稱:netmq,代碼行數:9,代碼來源:ZMQ.cs

示例2: Monitor

        public void Monitor(String addr, SocketEvent events)
        {
            if (m_ctxTerminated)
            {
                throw TerminatingException.Create();
            }

            // Support deregistering monitoring endpoints as well
            if (addr == null)
            {
                StopMonitor();
                return;
            }

            string address;
            string protocol;
            DecodeAddress(addr, out address, out protocol);

            CheckProtocol(protocol);

            // Event notification only supported over inproc://
            if (!protocol.Equals(Address.InProcProtocol))
            {
                throw NetMQException.Create(ErrorCode.EPROTONOSUPPORT);
            }

            // Register events to monitor
            m_monitorEvents = events;

            m_monitorSocket = Ctx.CreateSocket(ZmqSocketType.Pair);
            if (m_monitorSocket == null)
                throw NetMQException.Create(ErrorCode.EFAULT);

            // Never block context termination on pending event messages
            int linger = 0;

            try
            {
                m_monitorSocket.SetSocketOption(ZmqSocketOptions.Linger, linger);
            }
            catch (NetMQException)
            {
                StopMonitor();
                throw;
            }

            // Spawn the monitor socket endpoint
            try
            {
                m_monitorSocket.Bind(addr);
            }
            catch (NetMQException)
            {
                StopMonitor();
                throw;
            }
        }
開發者ID:hecwow,項目名稱:netmq,代碼行數:57,代碼來源:SocketBase.cs

示例3: Monitor

        public void Monitor([CanBeNull] string addr, SocketEvent events)
        {
            CheckContextTerminated();

            // Support de-registering monitoring endpoints as well
            if (addr == null)
            {
                StopMonitor();
                return;
            }

            string address;
            string protocol;
            DecodeAddress(addr, out address, out protocol);

            CheckProtocol(protocol);

            // Event notification only supported over inproc://
            if (!protocol.Equals(Address.InProcProtocol))
            {
                throw new ProtocolNotSupportedException(string.Format("In SocketBase.Monitor({0},), protocol must be inproc", addr));
            }

            // Register events to monitor
            m_monitorEvents = events;

            m_monitorSocket = Ctx.CreateSocket(ZmqSocketType.Pair);
            if (m_monitorSocket == null)
                throw new FaultException("In SocketBase.Monitor, Ctx.CreateSocket(ZmqSocketType.Pair) failed.");

            // Never block context termination on pending event messages
            const int linger = 0;

            try
            {
                m_monitorSocket.SetSocketOption(ZmqSocketOptions.Linger, linger);
            }
            catch (NetMQException)
            {
                StopMonitor();
                throw;
            }

            // Spawn the monitor socket endpoint
            try
            {
                m_monitorSocket.Bind(addr);
            }
            catch (NetMQException)
            {
                StopMonitor();
                throw;
            }
        }
開發者ID:bbqchickenrobot,項目名稱:netmq,代碼行數:54,代碼來源:SocketBase.cs

示例4: Monitor

        public bool Monitor(String addr, SocketEvent events)
        {
            bool rc;
            if (m_ctxTerminated)
            {
                ZError.ErrorNumber = (ErrorNumber.ETERM);
                return false;
            }

            // Support deregistering monitoring endpoints as well
            if (addr == null)
            {
                StopMonitor();
                return true;
            }

            //  Parse addr_ string.
            //Uri uri;
            //try
            //{
            //  uri = new Uri(addr);
            //}
            //catch (UriFormatException ex)
            //{
            //  ZError.ErrorNumber = (ErrorNumber.EINVAL);
            //  throw new ArgumentException(addr, ex);
            //}
            //String protocol = uri.Scheme;
            //String address = uri.Authority;
            //String path = uri.AbsolutePath;
            //if (string.IsNullOrEmpty(address))
            //  address = path;

            string address;
            string protocol;
            DecodeAddress(addr, out address, out protocol);

            CheckProtocol(protocol);

            // Event notification only supported over inproc://
            if (!protocol.Equals("inproc"))
            {
                ZError.ErrorNumber = (ErrorNumber.EPROTONOSUPPORT);
                return false;
            }

            // Register events to monitor
            m_monitorEvents = events;

            m_monitorSocket = Ctx.CreateSocket(ZmqSocketType.Pair);
            if (m_monitorSocket == null)
                return false;

            // Never block context termination on pending event messages
            int linger = 0;
            rc = m_monitorSocket.SetSocketOption(ZmqSocketOptions.Linger, linger);
            if (!rc)
                StopMonitor();

            // Spawn the monitor socket endpoint
            rc = m_monitorSocket.Bind(addr);
            if (!rc)
                StopMonitor();
            return rc;
        }
開發者ID:oskarwkarlsson,項目名稱:netmq,代碼行數:65,代碼來源:SocketBase.cs

示例5: SetSocketOption

        public static void SetSocketOption(SocketBase s, ZmqSocketOptions option, Object optval)
        {
            if (s == null || !s.CheckTag())
            {
                throw new InvalidOperationException();
            }

            s.SetSocketOption(option, optval);
        }
開發者ID:oskarwkarlsson,項目名稱:netmq,代碼行數:9,代碼來源:ZMQ.cs


注:本文中的NetMQ.zmq.SocketBase.SetSocketOption方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。