summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/UdpTransceiver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/UdpTransceiver.cpp')
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 67e2b33bc78..1fa3fb8e5eb 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -474,6 +474,21 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
}
else
{
+#ifndef _WIN32
+ //
+ // Enable SO_REUSEADDR on Unix platforms to allow re-using
+ // the socket even if it's in the TIME_WAIT state. On
+ // Windows, this doesn't appear to be necessary and
+ // enabling SO_REUSEADDR would actually not be a good
+ // thing since it allows a second process to bind to an
+ // address even it's already bound by another process.
+ //
+ // TODO: using SO_EXCLUSIVEADDRUSE on Windows would
+ // probably be better but it's only supported by recent
+ // Windows versions (XP SP2, Windows Server 2003).
+ //
+ setReuseAddress(_fd, true);
+#endif
doBind(_fd, _addr);
}