public Req(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_receivingReply = false; m_messageBegins = true; m_options.SocketType = ZmqSocketType.Req; }
public Pull(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_options.SocketType = ZmqSocketType.Pull; m_fq = new FQ(); }
public Push(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_options.SocketType = ZmqSocketType.Push; lb = new LB(); }
public Router(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_prefetched = false; m_identitySent = false; m_moreIn = false; m_currentOut = null; m_moreOut = false; m_nextPeerId = Utils.GenerateRandom (); m_mandatory = 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; }
public Rep(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_sendingReply = false; m_requestBegins = true; m_options.SocketType = ZmqSocketType.Rep; }
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; }
public IOThread(Ctx ctx, int tid) : base(ctx, tid) { m_name = "iothread-" + tid; 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); }
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 Deque<Blob>(); }
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(); }
// 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>(); }
public Reaper(Ctx ctx, int tid) : base(ctx, tid) { m_sockets = 0; m_terminating = false; m_name = "reaper-" + tid; 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); }
// 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; }
protected SocketBase(Ctx parent, int tid, int sid) : base(parent, tid) { 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); }
public Pair(Ctx parent, int tid, int sid) : base(parent, tid, sid) { m_options.SocketType = ZmqSocketType.Pair; }
public static int CtxGet(Ctx ctx, ContextOption option) { if (ctx == null || !ctx.CheckTag()) { throw new InvalidOperationException(); } return ctx.Get(option); }
private static void CtxDestroy(Ctx ctx) { if (ctx == null || !ctx.CheckTag()) { throw new InvalidOperationException(); } ctx.Terminate(); }
public static void Term(Ctx ctx) { CtxDestroy(ctx); }
// Sockets public static SocketBase Socket(Ctx ctx, ZmqSocketType type) { if (ctx == null || !ctx.CheckTag()) { throw new InvalidOperationException(); } SocketBase s = ctx.CreateSocket(type); return s; }
public static void CtxSet(Ctx ctx, ContextOption option, int optval) { if (ctx == null || !ctx.CheckTag()) { throw new InvalidOperationException(); } ctx.Set(option, optval); }
// New context API public static Ctx CtxNew() { // Create 0MQ context. Ctx ctx = new Ctx(); return ctx; }
private Context(Ctx ctx) { m_ctx = ctx; }
// 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; default: throw new ArgumentException("type=" + type); } return s; }