Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

multicast.hpp 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. //
  2. // ip/multicast.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_IP_MULTICAST_HPP
  11. #define ASIO_IP_MULTICAST_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include <cstddef>
  17. #include "asio/ip/detail/socket_option.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace ip {
  21. namespace multicast {
  22. /// Socket option to join a multicast group on a specified interface.
  23. /**
  24. * Implements the IPPROTO_IP/IP_ADD_MEMBERSHIP socket option.
  25. *
  26. * @par Examples
  27. * Setting the option to join a multicast group:
  28. * @code
  29. * asio::ip::udp::socket socket(my_context);
  30. * ...
  31. * asio::ip::address multicast_address =
  32. * asio::ip::address::from_string("225.0.0.1");
  33. * asio::ip::multicast::join_group option(multicast_address);
  34. * socket.set_option(option);
  35. * @endcode
  36. *
  37. * @par Concepts:
  38. * SettableSocketOption.
  39. */
  40. #if defined(GENERATING_DOCUMENTATION)
  41. typedef implementation_defined join_group;
  42. #else
  43. typedef asio::ip::detail::socket_option::multicast_request<
  44. ASIO_OS_DEF(IPPROTO_IP),
  45. ASIO_OS_DEF(IP_ADD_MEMBERSHIP),
  46. ASIO_OS_DEF(IPPROTO_IPV6),
  47. ASIO_OS_DEF(IPV6_JOIN_GROUP)> join_group;
  48. #endif
  49. /// Socket option to leave a multicast group on a specified interface.
  50. /**
  51. * Implements the IPPROTO_IP/IP_DROP_MEMBERSHIP socket option.
  52. *
  53. * @par Examples
  54. * Setting the option to leave a multicast group:
  55. * @code
  56. * asio::ip::udp::socket socket(my_context);
  57. * ...
  58. * asio::ip::address multicast_address =
  59. * asio::ip::address::from_string("225.0.0.1");
  60. * asio::ip::multicast::leave_group option(multicast_address);
  61. * socket.set_option(option);
  62. * @endcode
  63. *
  64. * @par Concepts:
  65. * SettableSocketOption.
  66. */
  67. #if defined(GENERATING_DOCUMENTATION)
  68. typedef implementation_defined leave_group;
  69. #else
  70. typedef asio::ip::detail::socket_option::multicast_request<
  71. ASIO_OS_DEF(IPPROTO_IP),
  72. ASIO_OS_DEF(IP_DROP_MEMBERSHIP),
  73. ASIO_OS_DEF(IPPROTO_IPV6),
  74. ASIO_OS_DEF(IPV6_LEAVE_GROUP)> leave_group;
  75. #endif
  76. /// Socket option for local interface to use for outgoing multicast packets.
  77. /**
  78. * Implements the IPPROTO_IP/IP_MULTICAST_IF socket option.
  79. *
  80. * @par Examples
  81. * Setting the option:
  82. * @code
  83. * asio::ip::udp::socket socket(my_context);
  84. * ...
  85. * asio::ip::address_v4 local_interface =
  86. * asio::ip::address_v4::from_string("1.2.3.4");
  87. * asio::ip::multicast::outbound_interface option(local_interface);
  88. * socket.set_option(option);
  89. * @endcode
  90. *
  91. * @par Concepts:
  92. * SettableSocketOption.
  93. */
  94. #if defined(GENERATING_DOCUMENTATION)
  95. typedef implementation_defined outbound_interface;
  96. #else
  97. typedef asio::ip::detail::socket_option::network_interface<
  98. ASIO_OS_DEF(IPPROTO_IP),
  99. ASIO_OS_DEF(IP_MULTICAST_IF),
  100. ASIO_OS_DEF(IPPROTO_IPV6),
  101. ASIO_OS_DEF(IPV6_MULTICAST_IF)> outbound_interface;
  102. #endif
  103. /// Socket option for time-to-live associated with outgoing multicast packets.
  104. /**
  105. * Implements the IPPROTO_IP/IP_MULTICAST_TTL socket option.
  106. *
  107. * @par Examples
  108. * Setting the option:
  109. * @code
  110. * asio::ip::udp::socket socket(my_context);
  111. * ...
  112. * asio::ip::multicast::hops option(4);
  113. * socket.set_option(option);
  114. * @endcode
  115. *
  116. * @par
  117. * Getting the current option value:
  118. * @code
  119. * asio::ip::udp::socket socket(my_context);
  120. * ...
  121. * asio::ip::multicast::hops option;
  122. * socket.get_option(option);
  123. * int ttl = option.value();
  124. * @endcode
  125. *
  126. * @par Concepts:
  127. * GettableSocketOption, SettableSocketOption.
  128. */
  129. #if defined(GENERATING_DOCUMENTATION)
  130. typedef implementation_defined hops;
  131. #else
  132. typedef asio::ip::detail::socket_option::multicast_hops<
  133. ASIO_OS_DEF(IPPROTO_IP),
  134. ASIO_OS_DEF(IP_MULTICAST_TTL),
  135. ASIO_OS_DEF(IPPROTO_IPV6),
  136. ASIO_OS_DEF(IPV6_MULTICAST_HOPS)> hops;
  137. #endif
  138. /// Socket option determining whether outgoing multicast packets will be
  139. /// received on the same socket if it is a member of the multicast group.
  140. /**
  141. * Implements the IPPROTO_IP/IP_MULTICAST_LOOP socket option.
  142. *
  143. * @par Examples
  144. * Setting the option:
  145. * @code
  146. * asio::ip::udp::socket socket(my_context);
  147. * ...
  148. * asio::ip::multicast::enable_loopback option(true);
  149. * socket.set_option(option);
  150. * @endcode
  151. *
  152. * @par
  153. * Getting the current option value:
  154. * @code
  155. * asio::ip::udp::socket socket(my_context);
  156. * ...
  157. * asio::ip::multicast::enable_loopback option;
  158. * socket.get_option(option);
  159. * bool is_set = option.value();
  160. * @endcode
  161. *
  162. * @par Concepts:
  163. * GettableSocketOption, SettableSocketOption.
  164. */
  165. #if defined(GENERATING_DOCUMENTATION)
  166. typedef implementation_defined enable_loopback;
  167. #else
  168. typedef asio::ip::detail::socket_option::multicast_enable_loopback<
  169. ASIO_OS_DEF(IPPROTO_IP),
  170. ASIO_OS_DEF(IP_MULTICAST_LOOP),
  171. ASIO_OS_DEF(IPPROTO_IPV6),
  172. ASIO_OS_DEF(IPV6_MULTICAST_LOOP)> enable_loopback;
  173. #endif
  174. } // namespace multicast
  175. } // namespace ip
  176. } // namespace asio
  177. #include "asio/detail/pop_options.hpp"
  178. #endif // ASIO_IP_MULTICAST_HPP