Beispiel #1
0
        public Push(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Push;

            lb = new LB();
        }
Beispiel #2
0
        public Router(Ctx parent, int threadId, int sid)
            : base(parent, threadId, sid)
        {
            m_prefetched = false;
            m_identitySent = false;
            m_moreIn = false;
            m_currentOut = null;
            m_moreOut = false;
            m_nextPeerId = Utils.GenerateRandom();
            m_mandatory = false;
            m_rawSocket = false;

            m_options.SocketType = ZmqSocketType.Router;

            m_fq = new FQ();
            m_prefetchedId = new Msg();
            m_prefetchedMsg = new Msg();

            m_anonymousPipes = new HashSet<Pipe>();
            m_outpipes = new Dictionary<Blob, Outpipe>();

            //  TODO: Uncomment the following line when ROUTER will become true ROUTER
            //  rather than generic router socket.
            //  If peer disconnect there's noone to send reply to anyway. We can drop
            //  all the outstanding requests from that peer.
            //  options.delay_on_disconnect = false;

            m_options.RecvIdentity = true;
        }
Beispiel #3
0
 public Req(Ctx parent, int threadId, int sid)
     : base(parent, threadId, sid)
 {
     m_receivingReply = false;
     m_messageBegins = true;
     m_options.SocketType = ZmqSocketType.Req;
 }
Beispiel #4
0
        public Pull(Ctx parent, int threadId, int sid)
            : base(parent, threadId, sid)
        {
            m_options.SocketType = ZmqSocketType.Pull;

            m_fq = new FQ();
        }
Beispiel #5
0
        public Rep(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_sendingReply = false;
            m_requestBegins = true;

            m_options.SocketType = ZmqSocketType.Rep;
        }
Beispiel #6
0
        public Sub(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Sub;

            //  Switch filtering messages on (as opposed to XSUB which where the
            //  filtering is off).
            m_options.Filter = true;
        }
Beispiel #7
0
        /// <summary> Initializes a new instance of the <see cref="Own" /> class that is running on a thread outside of 0MQ infrastructure. </summary>
        /// <param name="parent">The parent context.</param>
        /// <param name="threadId">The thread id.</param>
        /// <remarks> Note that the owner is unspecified in the constructor. It'll be assigned later on using <see cref="SetOwner"/>
        /// when the object is plugged in. </remarks>
        protected Own(Ctx parent, int threadId)
            : base(parent, threadId)
        {
            m_terminating = false;
            m_processedSeqnum = 0;
            m_owner = null;
            m_termAcks = 0;

            m_options = new Options();
        }
Beispiel #8
0
        public IOThread(Ctx ctx, int threadId)
            : base(ctx, threadId)
        {
            m_name = "iothread-" + threadId;
            m_poller = new Poller(m_name);

            m_mailbox = new Mailbox(m_name);
            m_mailboxHandle = m_mailbox.FD;
            m_poller.AddFD (m_mailboxHandle, this);
            m_poller.SetPollin (m_mailboxHandle);
        }
Beispiel #9
0
        public XPub(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Xpub;
            m_verbose = false;
            m_more = false;

            m_subscriptions = new Mtrie();
            m_dist = new Dist();
            m_pending = new Queue<Blob>();
        }
Beispiel #10
0
        public XSub(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_options.SocketType = ZmqSocketType.Xsub;
            m_hasMessage = false;
            m_more = false;

            m_options.Linger = 0;
            m_fq = new FQ();
            m_dist = new Dist();
            m_subscriptions = new Trie();
        }
Beispiel #11
0
        //  Note that the owner is unspecified in the constructor.
        //  It'll be supplied later on when the object is plugged in.
        //  The object is not living within an I/O thread. It has it's own
        //  thread outside of 0MQ infrastructure.
        public Own(Ctx parent, int tid)
            : base(parent, tid)
        {
            m_terminating = false;
            m_sentSeqnum = new AtomicLong(0);
            m_processedSeqnum = 0;
            m_owner = null;
            m_termAcks = 0;

            m_options = new Options();
            owned = new HashSet<Own>();
        }
Beispiel #12
0
        public Reaper(Ctx ctx, int threadId)
            : base(ctx, threadId)
        {
            m_sockets = 0;
            m_terminating = false;
            m_name = "reaper-" + threadId;
            m_poller = new Poller(m_name);

            mailbox = new Mailbox(m_name);

            m_mailboxHandle = mailbox.FD;
            m_poller.AddFD(m_mailboxHandle, this);
            m_poller.SetPollin(m_mailboxHandle);
        }
Beispiel #13
0
        public Reaper(Ctx ctx, int threadId)
            : base(ctx, threadId)
        {
            m_sockets = 0;
            m_terminating = false;

            string name = "reaper-" + threadId;
            m_poller = new Utils.Poller(name);

            m_mailbox = new Mailbox(name);

            m_mailboxHandle = m_mailbox.Handle;
            m_poller.AddHandle(m_mailboxHandle, this);
            m_poller.SetPollin(m_mailboxHandle);
        }
Beispiel #14
0
        //  Holds the prefetched message.
        public Dealer(Ctx parent, int tid, int sid)
            : base(parent, tid, sid)
        {
            m_prefetched = false;
            m_options.SocketType = ZmqSocketType.Dealer;

            m_fq = new FQ();
            m_lb = new LB();
            //  TODO: Uncomment the following line when DEALER will become true DEALER
            //  rather than generic dealer socket.
            //  If the socket is closing we can drop all the outbound requests. There'll
            //  be noone to receive the replies anyway.
            //  options.delay_on_close = false;

            m_options.RecvIdentity = true;
        }
Beispiel #15
0
        public Stream(Ctx parent, int threadId, int sid)
            : base(parent, threadId, sid)
        {
            m_prefetched = false;
              m_identitySent = false;
              m_currentOut = null;
              m_moreOut = false;
              m_nextPeerId = Utils.GenerateRandom();

              m_options.SocketType = ZmqSocketType.Stream;

              m_fq = new FQ();
              m_prefetchedId = new Msg();
              m_prefetchedMsg = new Msg();

              m_outpipes = new Dictionary<Blob, Outpipe>();

              m_options.RawSocket = true;
        }
Beispiel #16
0
        protected SocketBase(Ctx parent, int threadId, int sid)
            : base(parent, threadId)
        {
            m_tag = 0xbaddecaf;
            m_ctxTerminated = false;
            m_destroyed = false;
            m_lastTsc = 0;
            m_ticks = 0;
            m_rcvMore = false;
            m_monitorSocket = null;
            m_monitorEvents = 0;

            m_options.SocketId = sid;

            m_endpoints = new Dictionary<string, Own>();
            m_pipes = new List<Pipe>();

            m_mailbox = new Mailbox("socket-" + sid);
        }
Beispiel #17
0
        private static void CtxDestroy(Ctx ctx)
        {
            if (ctx == null || !ctx.CheckTag())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            ctx.Terminate();
        }
Beispiel #18
0
 public static void Term(Ctx ctx)
 {
     CtxDestroy(ctx);
 }
Beispiel #19
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;
 }
Beispiel #20
0
 public static void CtxSet(Ctx ctx, ContextOption option, int optval)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     ctx.Set(option, optval);
 }
Beispiel #21
0
 //  New context API
 public static Ctx CtxNew()
 {
     //  Create 0MQ context.
     Ctx ctx = new Ctx();
     return ctx;
 }
Beispiel #22
0
 protected ZObject(Ctx ctx, int tid)
 {
     this.m_ctx = ctx;
     this.m_tid = tid;
 }
Beispiel #23
0
 private NetMQContext(Ctx ctx)
 {
     m_ctx = ctx;
 }
Beispiel #24
0
 private Context(Ctx ctx)
 {
     m_ctx = ctx;
 }
Beispiel #25
0
        //  Create a socket of a specified type.
        public static SocketBase Create(ZmqSocketType type, Ctx parent,
                                                                                                                                        int tid, int sid)
        {
            SocketBase s;
            switch (type)
            {

                case ZmqSocketType.Pair:
                    s = new Pair(parent, tid, sid);
                    break;
                case ZmqSocketType.Pub:
                    s = new Pub(parent, tid, sid);
                    break;
                case ZmqSocketType.Sub:
                    s = new Sub(parent, tid, sid);
                    break;
                case ZmqSocketType.Req:
                    s = new Req(parent, tid, sid);
                    break;
                case ZmqSocketType.Rep:
                    s = new Rep(parent, tid, sid);
                    break;
                case ZmqSocketType.Dealer:
                    s = new Dealer(parent, tid, sid);
                    break;
                case ZmqSocketType.Router:
                    s = new Router(parent, tid, sid);
                    break;
                case ZmqSocketType.Pull:
                    s = new Pull(parent, tid, sid);
                    break;
                case ZmqSocketType.Push:
                    s = new Push(parent, tid, sid);
                    break;

                case ZmqSocketType.Xpub:
                    s = new XPub(parent, tid, sid);
                    break;

                case ZmqSocketType.Xsub:
                    s = new XSub(parent, tid, sid);
                    break;
                case ZmqSocketType.Stream:
                    s = new Stream(parent, tid, sid);
                    break;
                default:
                    throw InvalidException.Create("type=" + type);
            }
            return s;
        }
Beispiel #26
0
 protected void RegisterEndpoint(String addr, Ctx.Endpoint endpoint)
 {
     m_ctx.RegisterEndpoint(addr, endpoint);
 }
Beispiel #27
0
        public Push(Ctx parent, int threadId, int sid) : base(parent, threadId, sid)
        {
            m_options.SocketType = ZmqSocketType.Push;

            lb = new LB();
        }
Beispiel #28
0
 public static int CtxGet(Ctx ctx, ContextOption option)
 {
     if (ctx == null || !ctx.CheckTag())
     {
         throw NetMQException.Create(ErrorCode.EFAULT);
     }
     return ctx.Get(option);
 }
Beispiel #29
0
 protected bool RegisterEndpoint(String addr, Ctx.Endpoint endpoint)
 {
     return m_ctx.RegisterEndpoint (addr, endpoint);
 }
Beispiel #30
0
 public Pair(Ctx parent, int threadId, int sid)
     : base(parent, threadId, sid)
 {
     m_options.SocketType = ZmqSocketType.Pair;
 }
Beispiel #31
0
 protected ZObject(Ctx ctx, int threadId)
 {
     this.m_ctx = ctx;
     this.m_threadId = threadId;
 }