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, wlan0 etc...).
  • 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