zmq_udp.txt 3.4 KB

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