diff --git a/src/session_impl.cpp b/src/session_impl.cpp index dc4a4152a..eeaa27886 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2157,8 +2157,14 @@ namespace aux { return; } + // SO_REUSEADDR on windows is a bit special. It actually allows + // two active sockets to bind to the same port. That means we + // may end up binding to the same socket as some other random + // application. Don't do it! +#ifndef TORRENT_WINDOWS error_code err; // ignore errors here s->sock->set_option(socket_acceptor::reuse_address(true), err); +#endif #if TORRENT_USE_IPV6 if (ep.protocol() == tcp::v6()) diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index 2cf1f9d2f..d5803eefe 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -100,9 +100,16 @@ void test_ssl(int test_idx) session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49075, 50000), "0.0.0.0", 0, alert_mask); session_settings sett; - // this disables outgoing SSL connections - sett.ssl_listen = 0; - if (!test.downloader_has_cert) ses2.set_settings(sett); + + sett.ssl_listen = 1024 + rand() % 50000; + ses1.set_settings(sett); + + if (!test.downloader_has_cert) + // this disables outgoing SSL connections + sett.ssl_listen = 0; + else + sett.ssl_listen += 10; + ses2.set_settings(sett); torrent_handle tor1; torrent_handle tor2;