v6_only.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // ip/v6_only.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 BOOST_ASIO_IP_V6_ONLY_HPP
  11. #define BOOST_ASIO_IP_V6_ONLY_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/detail/socket_option.hpp>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace ip {
  21. /// Socket option for determining whether an IPv6 socket supports IPv6
  22. /// communication only.
  23. /**
  24. * Implements the IPPROTO_IPV6/IP_V6ONLY socket option.
  25. *
  26. * @par Examples
  27. * Setting the option:
  28. * @code
  29. * boost::asio::ip::tcp::socket socket(my_context);
  30. * ...
  31. * boost::asio::ip::v6_only option(true);
  32. * socket.set_option(option);
  33. * @endcode
  34. *
  35. * @par
  36. * Getting the current option value:
  37. * @code
  38. * boost::asio::ip::tcp::socket socket(my_context);
  39. * ...
  40. * boost::asio::ip::v6_only option;
  41. * socket.get_option(option);
  42. * bool v6_only = option.value();
  43. * @endcode
  44. *
  45. * @par Concepts:
  46. * GettableSocketOption, SettableSocketOption.
  47. */
  48. #if defined(GENERATING_DOCUMENTATION)
  49. typedef implementation_defined v6_only;
  50. #elif defined(IPV6_V6ONLY)
  51. typedef boost::asio::detail::socket_option::boolean<
  52. IPPROTO_IPV6, IPV6_V6ONLY> v6_only;
  53. #else
  54. typedef boost::asio::detail::socket_option::boolean<
  55. boost::asio::detail::custom_socket_option_level,
  56. boost::asio::detail::always_fail_option> v6_only;
  57. #endif
  58. } // namespace ip
  59. } // namespace asio
  60. } // namespace boost
  61. #include <boost/asio/detail/pop_options.hpp>
  62. #endif // BOOST_ASIO_IP_V6_ONLY_HPP