Esempio n. 1
0
        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("inproc"))
            {
                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;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        // Sockets
        public static SocketBase Socket(Ctx ctx, ZmqSocketType type)
        {
            if (ctx == null || !ctx.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }
            SocketBase s = ctx.CreateSocket(type);

            return(s);
        }
Esempio n. 4
0
 // Sockets
 public static SocketBase Socket(Ctx ctx, ZmqSocketType type)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     SocketBase s = ctx.CreateSocket(type);
     return s;
 }
Esempio n. 5
0
 // Sockets
 public static SocketBase Socket(Ctx ctx, ZmqSocketType type)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw new InvalidOperationException();
     }
     SocketBase s = ctx.CreateSocket(type);
     return s;
 }