From f8bda070be17e8b0233c2ade3956bef4a5623fb1 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 10 May 2017 07:53:07 -0400 Subject: [PATCH] don't combine reuseaddr and exclusive addruse on windows --- src/session_impl.cpp | 6 ++++-- src/udp_socket.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 633a5edf5..e2bba7227 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1743,8 +1743,9 @@ namespace aux { error_code err; #ifdef TORRENT_WINDOWS ret.sock->set_option(exclusive_address_use(true), err); -#endif +#else ret.sock->set_option(tcp::acceptor::reuse_address(true), err); +#endif } #if TORRENT_USE_IPV6 @@ -5066,8 +5067,9 @@ retry: { #ifdef TORRENT_WINDOWS s.set_option(exclusive_address_use(true), ec); -#endif +#else s.set_option(tcp::acceptor::reuse_address(true), ec); +#endif // ignore errors because the underlying socket may not // be opened yet. This happens when we're routing through // a proxy. In that case, we don't yet know the address of diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index 73daeadf9..b12b7cc4e 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -799,8 +799,9 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) error_code err; #ifdef TORRENT_WINDOWS m_ipv4_sock.set_option(exclusive_address_use(true), err); -#endif +#else m_ipv4_sock.set_option(boost::asio::socket_base::reuse_address(true), err); +#endif m_ipv4_sock.bind(ep, ec); if (ec) return; @@ -825,8 +826,9 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) error_code err; #ifdef TORRENT_WINDOWS m_ipv6_sock.set_option(exclusive_address_use(true), err); -#endif +#else m_ipv6_sock.set_option(boost::asio::socket_base::reuse_address(true), err); +#endif m_ipv6_sock.set_option(boost::asio::ip::v6_only(true), err); m_ipv6_sock.bind(ep6, ec);