diff --git a/include/boost/asio/detail/socket_ops.hpp b/include/boost/asio/detail/socket_ops.hpp index 8e6fd96b..39e065b1 100644 --- a/include/boost/asio/detail/socket_ops.hpp +++ b/include/boost/asio/detail/socket_ops.hpp @@ -319,6 +319,12 @@ inline socket_type socket(int af, int type, int protocol, inline int setsockopt(socket_type s, int level, int optname, const void* optval, size_t optlen, boost::system::error_code& ec) { + if (level == custom_socket_option_level && optname == always_fail_option) + { + ec = boost::asio::error::invalid_argument; + return -1; + } + clear_error(ec); #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) return error_wrapper(::setsockopt(s, level, optname, @@ -332,6 +338,12 @@ inline int setsockopt(socket_type s, int level, int optname, inline int getsockopt(socket_type s, int level, int optname, void* optval, size_t* optlen, boost::system::error_code& ec) { + if (level == custom_socket_option_level && optname == always_fail_option) + { + ec = boost::asio::error::invalid_argument; + return -1; + } + clear_error(ec); #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) int tmp_optlen = static_cast(*optlen); diff --git a/include/boost/asio/detail/socket_types.hpp b/include/boost/asio/detail/socket_types.hpp index bf6c67f1..3a42e647 100644 --- a/include/boost/asio/detail/socket_types.hpp +++ b/include/boost/asio/detail/socket_types.hpp @@ -170,6 +170,7 @@ const int message_do_not_route = MSG_DONTROUTE; #endif const int custom_socket_option_level = 0xA5100000; const int enable_connection_aborted_option = 1; +const int always_fail_option = 2; } // namespace detail } // namespace asio diff --git a/include/boost/asio/ip/v6_only.hpp b/include/boost/asio/ip/v6_only.hpp index efe36749..78285fd2 100644 --- a/include/boost/asio/ip/v6_only.hpp +++ b/include/boost/asio/ip/v6_only.hpp @@ -52,9 +52,13 @@ namespace ip { */ #if defined(GENERATING_DOCUMENTATION) typedef implementation_defined v6_only; -#else +#elif defined(IPV6_V6ONLY) typedef boost::asio::detail::socket_option::boolean< IPPROTO_IPV6, IPV6_V6ONLY> v6_only; +#else +typedef boost::asio::detail::socket_option::boolean< + boost::asio::detail::custom_socket_option_level, + boost::asio::detail::always_fail_option> v6_only; #endif } // namespace ip