ZMQ_MSG_GETS(3)
ZMQ_MSG_GETS π (3)
okay so bestie, welcome to the 0MQ Manual section 3 β this is the one where we get metadata properties off a message, and honestly? it's giving β¨detective energyβ¨. let's go. π΅οΈβοΈ
πΈ NAME πΈ
zmq_msg_gets β get message metadata property. that's it, that's the whole vibe. π
β¨ SYNOPSIS β¨
const char *zmq_msg_gets (zmq_msg_t *message, const char *property);
π DESCRIPTION π
so the zmq_msg_gets() function shall return the string value for the metadata property you asked for β that's the property argument β for the message that message points at. both the property argument and the value are NULL-terminated UTF8-encoded strings, no cap. π§
metadata gets defined on a per-connection basis during the ZeroMQ connection handshake, as specified in <rfc.zeromq.org/spec:37>. your app can set metadata properties using the ZMQ_METADATA option of zmq_setsockopt(3). and bestie, listen β application metadata properties must be prefixed with X-. no X-, no entry. periodt. π
on top of application metadata, these ZMTP properties can be retrieved with zmq_msg_gets() too:
Socket-TypeRouting-Id
note:Identityis a deprecated alias forRouting-Id. it's giving "still works but please move on" π
also, when it's available for the underlying transport, the Peer-Address property will return the IP address of the remote endpoint, exactly as returned by getnameinfo(2). slay. π₯
the names of these properties are also defined in zmq.h as ZMQ_MSG_PROPERTY_SOCKET_TYPE, ZMQ_MSG_PROPERTY_ROUTING_ID, and ZMQ_MSG_PROPERTY_PEER_ADDRESS. currently these definitions are only available as a DRAFT API β so like, handle with care, she's still in beta. π
other properties may be defined based on the underlying security mechanism β see the ZAP authenticated connection sample below. π
π RETURN VALUE π
if it works, zmq_msg_gets() shall return the string value for the property. if not, it shall return NULL and set errno to one of the values defined below. π«Ά
and this is important, bestie: the caller shall not modify or free the returned value β it shall be owned by the message. hands off, it's not yours. π«
the encoding of the property and the value shall be UTF8. always. π
π ERRORS π
EINVALβ the requested property is unknown. like, girl, who? never heard of her. π βοΈ
π EXAMPLE π
getting the ZAP authenticated user id for a message:
zmq_msg_t msg;
zmq_msg_init (&msg);
rc = zmq_msg_recv (&msg, dealer, 0);
assert (rc != -1);
const char *user_id = zmq_msg_gets (&msg, ZMQ_MSG_PROPERTY_USER_ID);
zmq_msg_close (&msg);
look at her go. iconic. β
π¦ SEE ALSO π¦
π AUTHORS π
this page was written by the 0MQ community. to make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. they're literally so welcoming, 10/10. π
and that's a wrap on the ZMQ_MSG_GETS(3) page from the 0MQ Manual, dated 10/09/2023, shipped with 0MQ 4.3.5 β go forth and read your metadata, bestie, you're gonna eat. π
β¨πΈ
π¦ 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