diff --git a/asio/include/asio/detail/impl/descriptor_ops.ipp b/asio/include/asio/detail/impl/descriptor_ops.ipp index 9e6d90bc95..c56a512e46 100644 --- a/asio/include/asio/detail/impl/descriptor_ops.ipp +++ b/asio/include/asio/detail/impl/descriptor_ops.ipp @@ -69,18 +69,25 @@ int close(int d, state_type& state, asio::error_code& ec) ::fcntl(d, F_SETFL, flags & ~O_NONBLOCK); #else // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) ioctl_arg_type arg = 0; -# if defined(ENOTTY) +# if defined(ENOTTY) || defined(ENOTCAPABLE) result = ::ioctl(d, FIONBIO, &arg); get_last_error(ec, result < 0); - if (ec.value() == ENOTTY) + if (false +# if defined(ENOTTY) + || ec.value() == ENOTTY +# endif // defined(ENOTTY) +# if defined(ENOTCAPABLE) + || ec.value() == ENOTCAPABLE +# endif // defined(ENOTCAPABLE) + ) { int flags = ::fcntl(d, F_GETFL, 0); if (flags >= 0) ::fcntl(d, F_SETFL, flags & ~O_NONBLOCK); } -# else // defined(ENOTTY) +# else // defined(ENOTTY) || defined(ENOTCAPABLE) ::ioctl(d, FIONBIO, &arg); -# endif // defined(ENOTTY) +# endif // defined(ENOTTY) || defined(ENOTCAPABLE) #endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) state &= ~non_blocking; @@ -114,8 +121,15 @@ bool set_user_non_blocking(int d, state_type& state, ioctl_arg_type arg = (value ? 1 : 0); int result = ::ioctl(d, FIONBIO, &arg); get_last_error(ec, result < 0); -# if defined(ENOTTY) - if (ec.value() == ENOTTY) +# if defined(ENOTTY) || defined(ENOTCAPABLE) + if (false +# if defined(ENOTTY) + || ec.value() == ENOTTY +# endif // defined(ENOTTY) +# if defined(ENOTCAPABLE) + || ec.value() == ENOTCAPABLE +# endif // defined(ENOTCAPABLE) + ) { result = ::fcntl(d, F_GETFL, 0); get_last_error(ec, result < 0); @@ -126,7 +140,7 @@ bool set_user_non_blocking(int d, state_type& state, get_last_error(ec, result < 0); } } -# endif // defined(ENOTTY) +# endif // defined(ENOTTY) || defined(ENOTCAPABLE) #endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) if (result >= 0) @@ -177,8 +191,15 @@ bool set_internal_non_blocking(int d, state_type& state, ioctl_arg_type arg = (value ? 1 : 0); int result = ::ioctl(d, FIONBIO, &arg); get_last_error(ec, result < 0); -# if defined(ENOTTY) - if (ec.value() == ENOTTY) +# if defined(ENOTTY) || defined(ENOTCAPABLE) + if (false +# if defined(ENOTTY) + || ec.value() == ENOTTY +# endif // defined(ENOTTY) +# if defined(ENOTCAPABLE) + || ec.value() == ENOTCAPABLE +# endif // defined(ENOTCAPABLE) + ) { result = ::fcntl(d, F_GETFL, 0); get_last_error(ec, result < 0); @@ -189,7 +210,7 @@ bool set_internal_non_blocking(int d, state_type& state, get_last_error(ec, result < 0); } } -# endif // defined(ENOTTY) +# endif // defined(ENOTTY) || defined(ENOTCAPABLE) #endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) if (result >= 0) diff --git a/asio/include/asio/detail/impl/socket_ops.ipp b/asio/include/asio/detail/impl/socket_ops.ipp index 6b447ffa82..7feb7ca02d 100644 --- a/asio/include/asio/detail/impl/socket_ops.ipp +++ b/asio/include/asio/detail/impl/socket_ops.ipp @@ -339,7 +339,25 @@ int close(socket_type s, state_type& state, ::fcntl(s, F_SETFL, flags & ~O_NONBLOCK); # else // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) ioctl_arg_type arg = 0; +# if defined(ENOTTY) || defined(ENOTCAPABLE) + result = ::ioctl(s, FIONBIO, &arg); + get_last_error(ec, result < 0); + if (false +# if defined(ENOTTY) + || ec.value() == ENOTTY +# endif // defined(ENOTTY) +# if defined(ENOTCAPABLE) + || ec.value() == ENOTCAPABLE +# endif // defined(ENOTCAPABLE) + ) + { + int flags = ::fcntl(s, F_GETFL, 0); + if (flags >= 0) + ::fcntl(s, F_SETFL, flags & ~O_NONBLOCK); + } +# else // defined(ENOTTY) || defined(ENOTCAPABLE) ::ioctl(s, FIONBIO, &arg); +# endif // defined(ENOTTY) || defined(ENOTCAPABLE) # endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__) state &= ~non_blocking; @@ -378,11 +396,31 @@ bool set_user_non_blocking(socket_type s, result = ::fcntl(s, F_SETFL, flag); get_last_error(ec, result < 0); } -#else +#else // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) ioctl_arg_type arg = (value ? 1 : 0); int result = ::ioctl(s, FIONBIO, &arg); get_last_error(ec, result < 0); -#endif +# if defined(ENOTTY) || defined(ENOTCAPABLE) + if (false +# if defined(ENOTTY) + || ec.value() == ENOTTY +# endif // defined(ENOTTY) +# if defined(ENOTCAPABLE) + || ec.value() == ENOTCAPABLE +# endif // defined(ENOTCAPABLE) + ) + { + result = ::fcntl(s, F_GETFL, 0); + get_last_error(ec, result < 0); + if (result >= 0) + { + int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK)); + result = ::fcntl(s, F_SETFL, flag); + get_last_error(ec, result < 0); + } + } +# endif // defined(ENOTTY) || defined(ENOTCAPABLE) +#endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) if (result >= 0) { @@ -432,11 +470,31 @@ bool set_internal_non_blocking(socket_type s, result = ::fcntl(s, F_SETFL, flag); get_last_error(ec, result < 0); } -#else +#else // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) ioctl_arg_type arg = (value ? 1 : 0); int result = ::ioctl(s, FIONBIO, &arg); get_last_error(ec, result < 0); -#endif +# if defined(ENOTTY) || defined(ENOTCAPABLE) + if (false +# if defined(ENOTTY) + || ec.value() == ENOTTY +# endif // defined(ENOTTY) +# if defined(ENOTCAPABLE) + || ec.value() == ENOTCAPABLE +# endif // defined(ENOTCAPABLE) + ) + { + result = ::fcntl(s, F_GETFL, 0); + get_last_error(ec, result < 0); + if (result >= 0) + { + int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK)); + result = ::fcntl(s, F_SETFL, flag); + get_last_error(ec, result < 0); + } + } +# endif // defined(ENOTTY) || defined(ENOTCAPABLE) +#endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__) if (result >= 0) {