Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Unified Diff: runtime/bin/socket_win.cc

Issue 25511002: Add reusePort argument to ServerSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mac os X version. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | sdk/lib/io/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698