[zeromq-dev] DOWNSTREAM persistence
ilejncs
ilejncs at narod.ru
Thu Jul 22 18:39:10 CEST 2010
Hello!
I need a one-way communication between one producer and several consumers.
I wrote a trivial client application
==
zmq::socket_t s (ctx, ZMQ_DOWNSTREAM);
int64_t number_of_messages = 2;
s.setsockopt(ZMQ_HWM, &number_of_messages, sizeof(int64_t));
// Connect it to port 23055 on localhost using the TCP transport
s.connect ("tcp://localhost:23055");
s.connect ("tcp://localhost:23056");
for(int i = 0; i < 10; ++i)
{
s.send (query);
}
sleep(<forever>)
==
When the Client (and only client) is run, is freezes after the 4th send, which perfectly conforms with ZMQ_DOWNSTREAM documentation.
When first Server application is run, it gets 8 messages (and Client goes further). This is understandable.
When second Server application is run, it gets nothing.
==
dev:~/projects/zeromq-play >./server 23056
Received query: 1(port 23056)
Received query: 3(port 23056)
Received query: 4(port 23056)
Received query: 5(port 23056)
Received query: 6(port 23056)
Received query: 7(port 23056)
Received query: 8(port 23056)
Received query: 9(port 23056)
C-c C-c
dev:~/projects/zeromq-play >./server 23055
C-c C-c
dev:~/projects/zeromq-play >
==
The question is why messages #0 and #2 are lost.
And other question.
I am not happy socket blocks if queue is full.
I need something like EAGAIN/exception/whatever indication in this case.
Is it achievable (e.g. for another socket type)?
Many thanks.
==
Best regards,
Ilja Golshtein.
More information about the zeromq-dev
mailing list