Ejemplo 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);
        }
Ejemplo n.º 2
0
        protected internal virtual Msg ReceiveInternal(SendReceiveOptions options, out bool hasMore)
        {
            var msg = ZMQ.Recv(m_socketHandle, options);

            hasMore = msg.HasMore;

            return(msg);
        }
Ejemplo n.º 3
0
        void puller_PollInHandler(ZMQ.Socket socket, ZMQ.IOMultiPlex revents)
        {
            var message = socket.Recv(UTF8Encoding.UTF8);

            Console.WriteLine("Message received" + message);
        }