summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2013-09-18 22:08:21 -0400
committercomex <comexk@gmail.com>2013-09-22 16:11:43 -0400
commitcf4d015b2aa63a472e262d736245224df4613627 (patch)
tree10dc20329fdaea0d63df6472feafa5fdcc7257e6
parent17e753faf3b44b98b6721a629056636aa4c3fe91 (diff)
Don't disable SO_REUSEADDR on non-Windows, where it is safe.
-rw-r--r--Externals/SFML/src/SFML/Network/SocketTCP.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/Externals/SFML/src/SFML/Network/SocketTCP.cpp b/Externals/SFML/src/SFML/Network/SocketTCP.cpp
index 8e9aa33f81..6cbd158aa8 100644
--- a/Externals/SFML/src/SFML/Network/SocketTCP.cpp
+++ b/Externals/SFML/src/SFML/Network/SocketTCP.cpp
@@ -488,18 +488,22 @@ void SocketTCP::Create(SocketHelper::SocketType Descriptor)
// Setup default options
if (IsValid())
{
- /* We must disable this in order to detect if ports are being used by other apps, or
- other instances of dolphin. This is also disabled in SFML 2.0, see
- http://www.sfml-dev.org/forum/viewtopic.php?t=3388
+ int Yes = 1;
+#ifndef SFML_SYSTEM_WINDOWS
+ /* We must disable this in order to detect if ports are being used by other apps, or
+ other instances of dolphin. This is also disabled in SFML 2.0, see
+http://www.sfml-dev.org/forum/viewtopic.php?t=3388
+ ...In fact, SO_REUSEADDR is only unsafe on Windows. See:
+ http://stackoverflow.com/questions/14388706
+ */
// To avoid the "Address already in use" error message when trying to bind to the same port
if (setsockopt(mySocket, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&Yes), sizeof(Yes)) == -1)
{
std::cerr << "Failed to set socket option \"SO_REUSEADDR\" ; "
<< "binding to a same port may fail if too fast" << std::endl;
}
- */
+#endif
- int Yes = 1;
// Disable the Nagle algorithm (ie. removes buffering of TCP packets)
if (setsockopt(mySocket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>(&Yes), sizeof(Yes)) == -1)
{