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

Side by Side Diff: runtime/bin/socket_win.cc

Issue 14766003: Add v6Only named argument to ServerSocket and etc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 i++; 232 i++;
233 } 233 }
234 } 234 }
235 freeaddrinfo(info); 235 freeaddrinfo(info);
236 return addresses; 236 return addresses;
237 } 237 }
238 238
239 239
240 intptr_t ServerSocket::CreateBindListen(RawAddr addr, 240 intptr_t ServerSocket::CreateBindListen(RawAddr addr,
241 intptr_t port, 241 intptr_t port,
242 intptr_t backlog) { 242 intptr_t backlog,
243 bool v6_only) {
243 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, IPPROTO_TCP); 244 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, IPPROTO_TCP);
244 if (s == INVALID_SOCKET) { 245 if (s == INVALID_SOCKET) {
245 return -1; 246 return -1;
246 } 247 }
247 248
248 BOOL optval = true; 249 BOOL optval = true;
249 int status = setsockopt(s, 250 int status = setsockopt(s,
250 SOL_SOCKET, 251 SOL_SOCKET,
251 SO_REUSEADDR, 252 SO_REUSEADDR,
252 reinterpret_cast<const char*>(&optval), 253 reinterpret_cast<const char*>(&optval),
253 sizeof(optval)); 254 sizeof(optval));
254 if (status == SOCKET_ERROR) { 255 if (status == SOCKET_ERROR) {
255 DWORD rc = WSAGetLastError(); 256 DWORD rc = WSAGetLastError();
256 closesocket(s); 257 closesocket(s);
257 SetLastError(rc); 258 SetLastError(rc);
258 return -1; 259 return -1;
259 } 260 }
260 261
261 if (addr.ss.ss_family == AF_INET6) { 262 if (addr.ss.ss_family == AF_INET6) {
262 optval = false; 263 optval = v6_only;
263 setsockopt(s, 264 setsockopt(s,
264 IPPROTO_IPV6, 265 IPPROTO_IPV6,
265 IPV6_V6ONLY, 266 IPV6_V6ONLY,
266 reinterpret_cast<const char*>(&optval), 267 reinterpret_cast<const char*>(&optval),
267 sizeof(optval)); 268 sizeof(optval));
268 } 269 }
269 270
270 SocketAddress::SetAddrPort(&addr, port); 271 SocketAddress::SetAddrPort(&addr, port);
271 status = bind(s, 272 status = bind(s,
272 &addr.addr, 273 &addr.addr,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 IPPROTO_TCP, 327 IPPROTO_TCP,
327 TCP_NODELAY, 328 TCP_NODELAY,
328 reinterpret_cast<char *>(&on), 329 reinterpret_cast<char *>(&on),
329 sizeof(on)) == 0; 330 sizeof(on)) == 0;
330 } 331 }
331 332
332 } // namespace bin 333 } // namespace bin
333 } // namespace dart 334 } // namespace dart
334 335
335 #endif // defined(TARGET_OS_WINDOWS) 336 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698