Discussion:
[zeromq-dev] Simple PUB / SUB test does not work
Aurélien ....
2016-09-22 16:10:36 UTC
Permalink
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
Colin Ingarfield
2016-09-22 16:21:14 UTC
Permalink
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.
Post by Aurélien ....
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Dimos Stamatakis
2016-09-22 16:28:47 UTC
Permalink
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
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.
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Aurélien ....
2016-09-22 16:57:55 UTC
Permalink
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
Post by Dimos Stamatakis
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
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.
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Luca Boccassi
2016-09-22 17:12:49 UTC
Permalink
Windows has some weirdness on the localhost I think, try to avoid the
wildcard and bind and connect to 127.0.0.1
Post by Aurélien ....
Thank you for your replies.
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
Post by Dimos Stamatakis
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
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.
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Aurélien ....
2016-09-23 08:00:17 UTC
Permalink
I tried with 127.0.0.1 on bind and connect functions, it didn't worked.

I also tried on Linux (Ubuntu 16.04), same result.

Very strange !
Post by Luca Boccassi
Windows has some weirdness on the localhost I think, try to avoid the
wildcard and bind and connect to 127.0.0.1
Post by Aurélien ....
Thank you for your replies.
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
Post by Dimos Stamatakis
That's right. I remember reading this on the instructions on how to
build
Post by Aurélien ....
Post by Dimos Stamatakis
a pub-sub system in ZeroMQ. There is limited availability, since as Ian
said
Post by Aurélien ....
Post by Dimos Stamatakis
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 <
Post by Colin Ingarfield
The subscriber connect() call is asynchronous. It's possible the
publish
Post by Aurélien ....
Post by Dimos Stamatakis
Post by Colin Ingarfield
messages are sent before the subscribe socket connects and establishes
its
Post by Aurélien ....
Post by Dimos Stamatakis
Post by Colin Ingarfield
subscription.
Try sleeping for 100ms or so after the connect call, before the loop.
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Aurélien ....
2016-09-23 12:16:33 UTC
Permalink
Hi,

I had to increase the "sleep" to 5 seconds and it worked.

Strange !
Post by Aurélien ....
I tried with 127.0.0.1 on bind and connect functions, it didn't worked.
I also tried on Linux (Ubuntu 16.04), same result.
Very strange !
Post by Luca Boccassi
Windows has some weirdness on the localhost I think, try to avoid the
wildcard and bind and connect to 127.0.0.1
Post by Aurélien ....
Thank you for your replies.
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
Post by Dimos Stamatakis
That's right. I remember reading this on the instructions on how to
build
Post by Aurélien ....
Post by Dimos Stamatakis
a pub-sub system in ZeroMQ. There is limited availability, since as
Ian said
Post by Aurélien ....
Post by Dimos Stamatakis
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 <
Post by Colin Ingarfield
The subscriber connect() call is asynchronous. It's possible the
publish
Post by Aurélien ....
Post by Dimos Stamatakis
Post by Colin Ingarfield
messages are sent before the subscribe socket connects and
establishes its
Post by Aurélien ....
Post by Dimos Stamatakis
Post by Colin Ingarfield
subscription.
Try sleeping for 100ms or so after the connect call, before the loop.
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Luca Boccassi
2016-09-23 12:43:38 UTC
Permalink
Not that strange, the connect is asynchronous, so there is absolutely
no guarantee on when it actually happens, by design.

In production, if you need synch, either use an out-of-band control
channel (eg: req-rep) or switch to XPUB, which gives you notifications
of subscribe/unsubscribe.
Post by Aurélien ....
Hi,
I had to increase the "sleep" to 5 seconds and it worked.
Strange !
Post by Aurélien ....
I tried with 127.0.0.1 on bind and connect functions, it didn't worked.
I also tried on Linux (Ubuntu 16.04), same result.
Very strange !
Post by Luca Boccassi
Windows has some weirdness on the localhost I think, try to avoid the
wildcard and bind and connect to 127.0.0.1
Post by Aurélien ....
Thank you for your replies.
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
Post by Dimos Stamatakis
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
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.
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.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Aurélien ....
2016-09-26 16:23:37 UTC
Permalink
Big big error :

subscriber.setsockopt(ZMQ_SUBSCRIBE, "A");
=>
subscriber.setsockopt(ZMQ_SUBSCRIBE, "A", 1);

With this fix ( and Sleep(10) ), it works perfectly !

Thanks,

kin
Post by Luca Boccassi
Not that strange, the connect is asynchronous, so there is absolutely
no guarantee on when it actually happens, by design.
In production, if you need synch, either use an out-of-band control
channel (eg: req-rep) or switch to XPUB, which gives you notifications
of subscribe/unsubscribe.
Post by Aurélien ....
Hi,
I had to increase the "sleep" to 5 seconds and it worked.
Strange !
Post by Aurélien ....
I tried with 127.0.0.1 on bind and connect functions, it didn't worked.
I also tried on Linux (Ubuntu 16.04), same result.
Very strange !
Post by Luca Boccassi
Windows has some weirdness on the localhost I think, try to avoid the
wildcard and bind and connect to 127.0.0.1
Post by Aurélien ....
Thank you for your replies.
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 <
Post by Dimos Stamatakis
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
Post by Aurélien ....
Post by Aurélien ....
Post by Luca Boccassi
Post by Aurélien ....
Post by Dimos Stamatakis
building something reliable and make it fast.
Dimos
On Thu, Sep 22, 2016 at 12:21 PM, Colin Ingarfield
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.
Post by Aurélien ....
Post by Aurélien ....
Post by Luca Boccassi
Post by Aurélien ....
Post by Dimos Stamatakis
Hi,
I'm trying to make a simple PUB / SUB test.
First, I created the publisher, then the subscriber with a message
to
Post by Aurélien ....
Post by Aurélien ....
Post by Luca Boccassi
Post by Aurélien ....
Post by Dimos Stamatakis
subscribe.
Second, I send some messages from the publisher and I try to
retreive
Post by Aurélien ....
Post by Aurélien ....
Post by Luca Boccassi
Post by Aurélien ....
Post by Dimos Stamatakis
them from the subscriber.
The code compiles but the subscriber does not receive any data.
- Windows 7 / Visual Studio 2015
- Compile in /MTd (debug)
- ZMQ Version : 4.1.4
#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 list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Loading...