mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 10:33:52 +01:00
Added test and doc section for ZMQ_SHARED message flag
This commit is contained in:
parent
3497244c41
commit
82282d6973
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user