Added test and doc section for ZMQ_SHARED message flag

This commit is contained in:
Thomas Rodgers 2014-07-12 18:05:49 -05:00
parent 3497244c41
commit 82282d6973
2 changed files with 24 additions and 0 deletions

View File

@ -29,6 +29,10 @@ allows application to retrieve the remote endpoint via 'getpeername(2)'. Be
aware that the respective socket might be closed already, reused even.
Currently only implemented for TCP sockets.
*ZMQ_SHARED*::
Indicates that a message has been copied and MAY share underlying storage
with another copy of this message.
RETURN VALUE
------------
The _zmq_msg_get()_ function shall return the value for the property if

View File

@ -65,6 +65,26 @@ int main (void)
more = zmq_msg_more (&msg);
assert (more == 0);
// Test ZMQ_SHARED property
zmq_msg_t msg_a;
rc = zmq_msg_init_size(&msg_a, 1024); // large enough to be a type_lmsg
assert (rc == 0);
// Message is not shared
rc = zmq_msg_get(&msg_a, ZMQ_SHARED);
assert (rc == 0);
zmq_msg_t msg_b;
rc = zmq_msg_init(&msg_b);
assert (rc == 0);
rc = zmq_msg_copy(&msg_b, &msg_a);
assert (rc == 0);
// Message is now shared
rc = zmq_msg_get(&msg_b, ZMQ_SHARED);
assert (rc == 1);
// Deallocate the infrastructure.
rc = zmq_close (sc);
assert (rc == 0);