Commit 82282d69 authored by Thomas Rodgers's avatar Thomas Rodgers

Added test and doc section for ZMQ_SHARED message flag

parent 3497244c
...@@ -29,6 +29,10 @@ allows application to retrieve the remote endpoint via 'getpeername(2)'. Be ...@@ -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. aware that the respective socket might be closed already, reused even.
Currently only implemented for TCP sockets. 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 RETURN VALUE
------------ ------------
The _zmq_msg_get()_ function shall return the value for the property if The _zmq_msg_get()_ function shall return the value for the property if
......
...@@ -65,6 +65,26 @@ int main (void) ...@@ -65,6 +65,26 @@ int main (void)
more = zmq_msg_more (&msg); more = zmq_msg_more (&msg);
assert (more == 0); 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. // Deallocate the infrastructure.
rc = zmq_close (sc); rc = zmq_close (sc);
assert (rc == 0); assert (rc == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment