ZMQ_UDP(7)
π NAME π
zmq_udp β the 0MQ UDP multicast and unicast transport, bestie. Yes that's a whole transport and yes it's serving π¦
β¨ SYNOPSIS β¨
UDP is an unreliable protocol transport of data over IP networks. It supports both unicast and multicast communication. Like, it's giving "no promises but very fast" energy π
πΈ DESCRIPTION πΈ
Okay so real talk: the UDP transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket types. That's it. That's the list. No other socket types get to play π
π¦ ADDRESSING π¦
A 0MQ endpoint is a string, and it's built like transport:// followed by an address. The transport part says which underlying protocol we're using, and the address part says the transport-specific address you're connecting to. Slay, structure π
For the UDP transport, the transport is literally udp. What the address part means? Keep reading bestie, it's all below β¬οΈ
π BINDING A SOCKET π
With udp, we can only bind the ZMQ_DISH socket type. (Yeah, only the one. Dish only. That's the rule, no cap.)
When you bind a socket using zmq_bind() with the udp transport, the endpoint gets interpreted as an interface, then a colon, then the UDP port number to use.
An interface can be specified by any one of these:
- The wild-card
*, which means all available interfaces. - The name of the network interface (i.e.
eth0,lo,wlan0etc...). - The primary address assigned to the interface, in its numeric representation.
- A multicast address in its numeric representation that the socket should join.
The UDP port number can be a numeric value, usually above 1024 on POSIX systems. Noted, queen π«Ά
π CONNECTING A SOCKET π
With udp, we can only connect the ZMQ_RADIO socket type. (Radio only, dish stays home. Periodt.)
When you connect a socket to a peer address using zmq_connect() with the udp transport, the endpoint gets interpreted as a peer address, then a colon, then the UDP port number to use.
A peer address can be specified by either of these:
- The IPv4 or IPv6 address of the peer, in its numeric representation or using its hostname.
- A multicast address in its numeric representation.
π EXAMPLES π
Binding a socket π
// Unicast - UDP port 5555 on all available interfaces
rc = zmq_bind(dish, "udp://*:5555");
assert (rc == 0);
// Unicast - UDP port 5555 on the local loop-back interface
rc = zmq_bind(dish, "udp://127.0.0.1:5555");
assert (rc == 0);
// Unicast - UDP port 5555 on interface eth1
rc = zmq_bind(dish, "udp://eth1:5555");
assert (rc == 0);
// Multicast - UDP port 5555 on a Multicast address
rc = zmq_bind(dish, "udp://239.0.0.1:5555");
assert (rc == 0);
// Same as above but joining only on interface eth0
rc = zmq_bind(dish, "udp://eth0;239.0.0.1:5555");
assert (rc == 0);
// Same as above using IPv6 multicast
rc = zmq_bind(dish, "udp://eth0;[ff02::1]:5555");
assert (rc == 0);
Connecting a socket π«
// Connecting using an Unicast IP address
rc = zmq_connect(radio, "udp://192.168.1.1:5555");
assert (rc == 0);
// Connecting using a Multicast address
rc = zmq_connect(socket, "udp://239.0.0.1:5555);
assert (rc == 0);
// Connecting using a Multicast address using local interface wlan0
rc = zmq_connect(socket, "udp://wlan0;239.0.0.1:5555);
assert (rc == 0);
// Connecting to IPv6 multicast
rc = zmq_connect(socket, "udp://[ff02::1]:5555);
assert (rc == 0);
π bestie those last few zmq_connect lines are copied exactly as the page has them β quotes and all. Not me fixing them, not me touching them, we do not editorialize in this house π
β SEE ALSO β
π AUTHORS π
This page was written by the 0MQ community. Wanna make a change? Read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. Go off, contributor π«Ά
And that's the whole page, babes β¨ this was 0MQ 4.3.5, dated 10/09/2023, and honestly? Iconic. Slay, stay unreliable, and remember: UDP doesn't promise you anything but it will show up πππ
π¦ 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