summaryrefslogtreecommitdiff
path: root/cppe/src/TcpTransport/Acceptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cppe/src/TcpTransport/Acceptor.cpp')
-rw-r--r--cppe/src/TcpTransport/Acceptor.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/cppe/src/TcpTransport/Acceptor.cpp b/cppe/src/TcpTransport/Acceptor.cpp
index 72e53c7ace9..b32928219ec 100644
--- a/cppe/src/TcpTransport/Acceptor.cpp
+++ b/cppe/src/TcpTransport/Acceptor.cpp
@@ -116,6 +116,21 @@ IceInternal::Acceptor::Acceptor(const InstancePtr& instance, const string& host,
_fd = createSocket();
getAddress(host, port, _addr);
setTcpBufSize(_fd, _instance->initializationData().properties, _logger);
+#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
if(_traceLevels->network >= 2)
{
Trace out(_logger, _traceLevels->networkCat);