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
 /// <summary>
 /// Bind the socket to an address
 /// </summary>
 /// <param name="address">The address of the socket</param>
 public void Bind(string address)
 {
     ZMQ.Bind(m_socketHandle, address);
 }