Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
c1b374fa
Commit
c1b374fa
authored
Feb 05, 2019
by
Luca Boccassi
Committed by
Luca Boccassi
Feb 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: manpage for zmq_socket_monitor_versioned has old example
Solution: update it
parent
83946d5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
17 deletions
+45
-17
zmq_socket_monitor_versioned.txt
doc/zmq_socket_monitor_versioned.txt
+45
-17
No files found.
doc/zmq_socket_monitor_versioned.txt
View file @
c1b374fa
...
...
@@ -41,8 +41,9 @@ Each event is sent in multiple frames. The first frame contains an event
number (64 bits). The number and content of further frames depend on this
event number.
For all currently defined event types
, the second frame contains an event
Unless it is specified differently
, the second frame contains an event
value (64 bits) that provides additional data according to the event number.
Some events might define additional value frames following the second one.
The third and fourth frames contain strings that specifies the affected
connection or endpoint. The third frame contains a string denoting the local
endpoint, while the fourth frame contains a string denoting the remote endpoint.
...
...
@@ -62,7 +63,7 @@ to multiple endpoints using different transports.
----
Supported events
Supported events
(v1)
----------------
ZMQ_EVENT_CONNECTED
...
...
@@ -196,34 +197,61 @@ EXAMPLE
// by reference, if not null, and event number by value. Returns -1
// in case of error.
static
in
t
get_monitor_event (void *monitor,
int *value, char **
address)
static
uint64_
t
get_monitor_event (void *monitor,
uint64_t *value, char **local_address, char **remote_
address)
{
// First frame in message contains event number
and value
// First frame in message contains event number
zmq_msg_t msg;
zmq_msg_init (&msg);
if (zmq_msg_recv (&msg, monitor, 0) == -1)
return -1; // Interrupted, presumably
assert (zmq_msg_more (&msg));
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
uint16_t event = *(uint16_t *) (data);
if (value)
*value = *(uint32_t *) (data + 2);
uint64_t event;
memcpy (&event, zmq_msg_data (&msg), sizeof (event));
zmq_msg_close (&msg);
// Second frame in message contains event address
// Second frame to Nth frame (depends on the event) in message
// contains event value
zmq_msg_init (&msg);
if (zmq_msg_recv (&msg, monitor, 0) == -1)
return -1; // Interrupted, presumably
assert (zmq_msg_more (&msg));
if (value_)
memcpy (value_, zmq_msg_data (&msg), sizeof *value_);
zmq_msg_close (&msg);
// Third frame in message contains local address
zmq_msg_init (&msg);
if (zmq_msg_recv (&msg, monitor, 0) == -1)
return -1; // Interrupted, presumably
assert (zmq_msg_more (&msg));
if (local_address_) {
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
size_t size = zmq_msg_size (&msg);
*local_address_ = (char *) malloc (size + 1);
memcpy (*local_address_, data, size);
(*local_address_)[size] = 0;
}
zmq_msg_close (&msg);
// Fourth frame in message contains remote address
zmq_msg_init (&msg);
if (zmq_msg_recv (&msg, monitor, 0) == -1)
return -1; // Interrupted, presumably
assert (!zmq_msg_more (&msg));
if (
address
) {
if (
remote_address_
) {
uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
size_t size = zmq_msg_size (&msg);
*
address
= (char *) malloc (size + 1);
memcpy (*
address
, data, size);
(*
address
)[size] = 0;
*
remote_address_
= (char *) malloc (size + 1);
memcpy (*
remote_address_
, data, size);
(*
remote_address_
)[size] = 0;
}
zmq_msg_close (&msg);
return event;
}
...
...
@@ -239,14 +267,14 @@ int main (void)
assert (server);
// Socket monitoring only works over inproc://
int rc = zmq_socket_monitor
(client, "tcp://127.0.0.1:9999", 0
);
int rc = zmq_socket_monitor
_versioned (client, "tcp://127.0.0.1:9999", 0, 2
);
assert (rc == -1);
assert (zmq_errno () == EPROTONOSUPPORT);
// Monitor all events on client and server sockets
rc = zmq_socket_monitor
(client, "inproc://monitor-client", ZMQ_EVENT_ALL
);
rc = zmq_socket_monitor
_versioned (client, "inproc://monitor-client", ZMQ_EVENT_ALL, 2
);
assert (rc == 0);
rc = zmq_socket_monitor
(server, "inproc://monitor-server", ZMQ_EVENT_ALL
);
rc = zmq_socket_monitor
_versioned (server, "inproc://monitor-server", ZMQ_EVENT_ALL, 2
);
assert (rc == 0);
// Create two sockets for collecting monitor events
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment