1ZMQ_UDP(7) 0MQ Manual ZMQ_UDP(7)
2
3
4
6 zmq_udp - 0MQ UDP multicast and unicast transport
7
9 UDP is unreliable protocol transport of data over IP networks. UDP
10 support both unicast and multicast communication.
11
13 UDP transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket
14 types.
15
17 A 0MQ endpoint is a string consisting of a transport:// followed by an
18 address. The transport specifies the underlying protocol to use. The
19 address specifies the transport-specific address to connect to.
20
21 For the UDP transport, the transport is udp. The meaning of the address
22 part is defined below.
23
24 Binding a socket
25
26 With 'udp' we can only bind the 'ZMQ_DISH' socket type.
27 When binding a socket using _zmq_bind()_ with the 'udp'
28 transport the 'endpoint' shall be interpreted as an 'interface' followed by a
29 colon and the UDP port number to use.
30
31 An 'interface' may be specified by either of the following:
32
33 * The wild-card `*`, meaning all available interfaces.
34 * The name of the network interface (i.e. eth0, lo, wlan0 etc...)
35 * The primary address assigned to the interface, in its numeric representation.
36 * Multicast address in its numeric representation the socket should join.
37
38 The UDP port number may be specified a numeric value, usually above
39 1024 on POSIX systems.
40
41 Connecting a socket
42
43 With udp we can only connect the ZMQ_RADIO socket type. When connecting
44 a socket to a peer address using zmq_connect() with the udp transport,
45 the endpoint shall be interpreted as a peer address followed by a colon
46 and the UDP port number to use.
47
48 A peer address may be specified by either of the following:
49
50 • The IPv4 or IPv6 address of the peer, in its numeric representation
51 or using its hostname.
52
53 • Multicast address in its numeric representation.
54
56 Binding a socket.
57
58 // Unicast - UDP port 5555 on all available interfaces
59 rc = zmq_bind(dish, "udp://*:5555");
60 assert (rc == 0);
61 // Unicast - UDP port 5555 on the local loop-back interface
62 rc = zmq_bind(dish, "udp://127.0.0.1:5555");
63 assert (rc == 0);
64 // Unicast - UDP port 5555 on interface eth1
65 rc = zmq_bind(dish, "udp://eth1:5555");
66 assert (rc == 0);
67 // Multicast - UDP port 5555 on a Multicast address
68 rc = zmq_bind(dish, "udp://239.0.0.1:5555");
69 assert (rc == 0);
70 // Same as above but joining only on interface eth0
71 rc = zmq_bind(dish, "udp://eth0;239.0.0.1:5555");
72 assert (rc == 0);
73 // Same as above using IPv6 multicast
74 rc = zmq_bind(dish, "udp://eth0;[ff02::1]:5555");
75 assert (rc == 0);
76
77 Connecting a socket.
78
79 // Connecting using an Unicast IP address
80 rc = zmq_connect(radio, "udp://192.168.1.1:5555");
81 assert (rc == 0);
82 // Connecting using a Multicast address
83 rc = zmq_connect(socket, "udp://239.0.0.1:5555);
84 assert (rc == 0);
85 // Connecting using a Multicast address using local interface wlan0
86 rc = zmq_connect(socket, "udp://wlan0;239.0.0.1:5555);
87 assert (rc == 0);
88 // Connecting to IPv6 multicast
89 rc = zmq_connect(socket, "udp://[ff02::1]:5555);
90 assert (rc == 0);
91
92
94 zmq_connect(3) zmq_setsockopt(3) zmq_tcp(7) zmq_ipc(7) zmq_inproc(7)
95 zmq_vmci(7) zmq(7)
96
98 This page was written by the 0MQ community. To make a change please
99 read the 0MQ Contribution Policy at
100 http://www.zeromq.org/docs:contributing.
101
102
103
1040MQ 4.3.4 01/22/2022 ZMQ_UDP(7)