Thank you for your replies.

I tried with that :

zmq::socket_t subscriber(context, ZMQ_SUB);
subscriber.connect("tcp://localhost:5563");
Sleep(1000);
subscriber.setsockopt(ZMQ_SUBSCRIBE, "A");
Sleep(1000);

And it stiil does not work.

I also tried with the ZMQ version 4.2.0, same result.

I forgot to tell that I'm using the static version of ZMQ (with the
ZMQ_STATIC preprocessor variable), maybe it has something to do ?

Thank you,

Kin

On Thu, Sep 22, 2016 at 6:28 PM, Dimos Stamatakis <dimsta...@gmail.com>
wrote:

> That's right. I remember reading this on the instructions on how to build
> a pub-sub system in ZeroMQ. There is limited availability, since as Ian
> said they wanted to build something fast and make it reliable, rather than
> building something reliable and make it fast.
>
> Dimos
>
> On Thu, Sep 22, 2016 at 12:21 PM, Colin Ingarfield <co...@ingarfield.com>
> wrote:
>
>> The subscriber connect() call is asynchronous.  It's possible the publish
>> messages are sent before the subscribe socket connects and establishes its
>> subscription.
>>
>> Try sleeping for 100ms or so after the connect call, before the loop.
>>
>>
>> On 9/22/16 11:10 AM, Aurélien .... wrote:
>>
>> Hi,
>>
>> I'm trying to make a simple PUB / SUB test.
>>
>> First, I created the publisher, then the subscriber with a message to
>> subscribe.
>>
>> Second, I send some messages from the publisher and I try to retreive
>> them from the subscriber.
>>
>> The code compiles but the subscriber does not receive any data.
>>
>> My config is :
>> - Windows 7 / Visual Studio 2015
>> - Compile in /MTd (debug)
>> - ZMQ Version : 4.1.4
>>
>> Here is the code :
>>
>> #include "zhelpers.hpp"
>>
>> void TestPubSub()
>> {
>> zmq::context_t context;
>> zmq::socket_t publisher(context, ZMQ_PUB);
>> zmq_bind(publisher, "tcp://*:5563");
>>
>> zmq::socket_t subscriber(context, ZMQ_SUB);
>> subscriber.connect("tcp://localhost:5563");
>> subscriber.setsockopt(ZMQ_SUBSCRIBE, "A");
>>
>> while (1) {
>> //  Write two messages, each with an envelope and content
>> s_sendmore(publisher, "A");
>> s_send(publisher, "We don't want to see this");
>> s_sendmore(publisher, "B");
>> s_send(publisher, "We would like to see this");
>>
>> //  Read envelope with address
>> std::string addr = s_recv(subscriber); // block here, waiting for
>> messages which does not come
>> //  Read message contents
>> std::string contents = s_recv(subscriber);
>> }
>> }
>>
>> int main(int argc, char** argv)
>> {
>> TestPubSub();
>> return 0;
>> }
>>
>> Can you tel me where I'm wrong ?
>>
>> Thank you very much,
>>
>> Kin
>>
>>
>> _______________________________________________
>> zeromq-dev mailing 
>> listzeromq-dev@lists.zeromq.orghttp://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev@lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to