diff options
Diffstat (limited to 'cpp/src/Ice/TcpAcceptor.cpp')
-rw-r--r-- | cpp/src/Ice/TcpAcceptor.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp index 2ffb6fd5a0d..3d3c28b787d 100644 --- a/cpp/src/Ice/TcpAcceptor.cpp +++ b/cpp/src/Ice/TcpAcceptor.cpp @@ -121,6 +121,21 @@ IceInternal::TcpAcceptor::TcpAcceptor(const InstancePtr& instance, const string& setBlock(_fd, false); 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); |