Exemplo n.º 1
0
        public void ShouldAllowInfinitePolling()
        {
            Ctx        contextNew = ZMQ.CtxNew();
            SocketBase receiver   = ZMQ.Socket(contextNew, ZmqSocketType.Dealer);

            ZMQ.Bind(receiver, "inproc://test");

            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(500);
                SocketBase sender = ZMQ.Socket(contextNew, ZmqSocketType.Dealer);
                ZMQ.Connect(sender, "inproc://test");
                ZMQ.Send(sender, "ping", SendReceiveOptions.None);
                ZMQ.Close(sender);
            });

            var pollItems = new PollItem[] { new PollItem(receiver, PollEvents.PollIn) };

            Assert.DoesNotThrow(() => ZMQ.Poll(pollItems, -1));

            var msg = ZMQ.Recv(receiver, SendReceiveOptions.DontWait);

            var actual = Encoding.ASCII.GetString(msg.Data, 0, msg.Size);

            Assert.AreEqual("ping", actual);

            ZMQ.Close(receiver);
            ZMQ.Term(contextNew);
        }
Exemplo n.º 2
0
        public virtual void Send(byte[] data, int length, SendReceiveOptions options)
        {
            Msg msg = new Msg(data, length, Options.CopyMessages);

            ZMQ.Send(m_socketHandle, msg, options);
        }