[zeromq-dev] Boost Unit Testing with 0MQ PUB/SUB Sockets

Sebastian Lauwers sebastian.lauwers at gmail.com
Fri Aug 31 09:52:02 CEST 2012

On 31/08/12 06:24, Daniel Ng wrote:
> Hi,

Hi Daniel,

> socket_t::getsockopt() seems to erroneously report 'ZMQ_RCVMORE', but only in a
> Boost Unit Test!
> Here' my Boost Unit Test code:

I wasn't able to reproduce this locally:

I did notice that the server dies very quickly, so if the unit test 
isn't launched quickly enough, it gets stuck:

$ ./server & sleep 3; ./unit
[1] 7321
[1]+  Done                    ./server
Running 1 test case...

Above, ./unit gets stuck.

If I run both immediately:

$ ./server & ./unit
[1] 7335
Running 1 test case...
[1024]00000000000000000000000000 ... <snip a lot of 0's>

*** No errors detected
[1]+  Done                    ./server

This is probably due to the following code:

>      sleep(2);
>      zmq::message_t message(1024);
>      memcpy(message.data(), data, 1024);

Basically, you send off a message without checking whether a client is 
connected. As I understand it, that message would be lost, as the server 
dies just after it.

Good luck,


More information about the zeromq-dev mailing list