v6_only.hpp 1.6 KB

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