ZMQ_MSG_ROUTING_ID(3)
π ZMQ_MSG_ROUTING_ID π
okay bestie, so this one's from the 0MQ Manual and it's literally so cute and short, we're gonna eat it up. it's a 3 page, meaning it's about a library function, and the function is zmq_msg_routing_id. yes queen, we're doing message routing IDs today. grab a boba. π§
β¨ NAME β¨
zmq_msg_routing_id β return routing ID for message, if any
like... that's it. that's the whole job. it gives you the routing ID of a message if there is one, and if there isn't, no drama, it just says zero. π
β¨ SYNOPSIS β¨
uint32_t zmq_msg_routing_id (zmq_msg_t *message);
one function, one pointer, one uint32_t coming back at ya. so clean. so iconic. π
β¨ DESCRIPTION β¨
so the way that zmq_msg_routing_id() works is: it returns the routing ID for the message, if any. that "if any" is doing a LOT of heavy lifting there, bestie, so let's talk about when you actually get one. π¦
the routing ID is set on all messages received from a ZMQ_SERVER socket. every single one. no cap.
and then β and this is the part where it gets useful β to send a message to a ZMQ_SERVER socket, you must set the routing ID of a connected ZMQ_CLIENT peer. so like, you can't just fire a message into the void and hope. you need the ID. it's giving "you need the guest list to get into the party." π
π oh and also: routing IDs are transient. meaning they are NOT forever. do not fall in love with a routing ID. do not store it in a little jar. it's a moment, not a marriage. remember that fr fr.
β¨ RETURN VALUE β¨
- if there is no routing ID, it returns
zero. simple. nothing. bye. π - otherwise it returns an unsigned 32-bit integer greater than zero. so like,
1and up. positive vibes only. β¨
so like, quick vibe check: 0 = no ID, >0 = yes ID. that's the whole test, bestie. π«Ά
β¨ EXAMPLE β¨
receiving a client message and routing ID. look at this lil guy go:
void *ctx = zmq_ctx_new ();
assert (ctx);
void *server = zmq_socket (ctx, ZMQ_SERVER);
assert (server);
int rc = zmq_bind (server, "tcp://127.0.0.1:8080");
assert (rc == 0);
zmq_msg_t message;
rc = zmq_msg_init (&message);
assert (rc == 0);
// Receive a message from socket
rc = zmq_msg_recv (server, &message, 0);
assert (rc != -1);
uint32_t routing_id = zmq_msg_routing_id (&message);
assert (routing_id);
okay so what's happening here: make a context, make a ZMQ_SERVER socket, bind it to "tcp://127.0.0.1:8080", init a message, receive into it, then pull the routing ID out with zmq_msg_routing_id. and the final assert (routing_id) is literally the plot twist β it passes because a message that came in from a ZMQ_SERVER socket has a routing ID. π
β¨ SEE ALSO β¨
zmq_msg_set_routing_id(3)β the other half of the duo, the setter to this getter. go read it, iykyk. π
β¨ AUTHORS β¨
this page was written by the 0MQ community. π«Ά if you wanna make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. the community said come thru and contribute, and honestly? slay.
okay that's the whole page, no notes. πΈ stay transient, stay iconic. this was the zmq_msg_routing_id page, 0MQ version 4.3.5, dated 10/09/2023 β mwah, love u, bye bestie! ππβ¨
π¦ where this page comes from
- epel 10: zeromq 4.3.5-18.el10_0 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms