Index: runtime/bin/socket_win.cc |
diff --git a/runtime/bin/socket_win.cc b/runtime/bin/socket_win.cc |
index 87a0b30e2f5350a91da3cfdd841f0967243d14ce..c559730e964fd61001133e9062fb60ba003092e3 100644 |
--- a/runtime/bin/socket_win.cc |
+++ b/runtime/bin/socket_win.cc |
@@ -337,18 +337,28 @@ AddressList<InterfaceSocketAddress>* Socket::ListInterfaces( |
intptr_t ServerSocket::CreateBindListen(RawAddr addr, |
intptr_t port, |
intptr_t backlog, |
- bool v6_only) { |
+ bool v6_only, |
+ bool reuse_port) { |
SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, IPPROTO_TCP); |
if (s == INVALID_SOCKET) { |
return -1; |
} |
BOOL optval = true; |
- int status = setsockopt(s, |
- SOL_SOCKET, |
- SO_EXCLUSIVEADDRUSE, |
- reinterpret_cast<const char*>(&optval), |
- sizeof(optval)); |
+ int status; |
+ if (reuse_port) { |
+ status = setsockopt(s, |
+ SOL_SOCKET, |
+ SO_REUSEADDR, |
+ reinterpret_cast<const char*>(&optval), |
+ sizeof(optval)); |
+ } else { |
+ status = setsockopt(s, |
+ SOL_SOCKET, |
+ SO_EXCLUSIVEADDRUSE, |
+ reinterpret_cast<const char*>(&optval), |
+ sizeof(optval)); |
+ } |
if (status == SOCKET_ERROR) { |
DWORD rc = WSAGetLastError(); |
closesocket(s); |