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

Side by Side Diff: runtime/bin/socket.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 "bin/io_buffer.h" 5 #include "bin/io_buffer.h"
6 #include "bin/socket.h" 6 #include "bin/socket.h"
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 377
378 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) { 378 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) {
379 Dart_EnterScope(); 379 Dart_EnterScope();
380 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0); 380 Dart_Handle socket_obj = Dart_GetNativeArgument(args, 0);
381 Dart_Handle host_obj = Dart_GetNativeArgument(args, 1); 381 Dart_Handle host_obj = Dart_GetNativeArgument(args, 1);
382 RawAddr addr; 382 RawAddr addr;
383 Dart_Handle result = GetSockAddr(host_obj, &addr); 383 Dart_Handle result = GetSockAddr(host_obj, &addr);
384 Dart_Handle port_obj = Dart_GetNativeArgument(args, 2); 384 Dart_Handle port_obj = Dart_GetNativeArgument(args, 2);
385 Dart_Handle backlog_obj = Dart_GetNativeArgument(args, 3); 385 Dart_Handle backlog_obj = Dart_GetNativeArgument(args, 3);
386 Dart_Handle v6_only_obj = Dart_GetNativeArgument(args, 4);
387 bool v6_only = DartUtils::GetBooleanValue(v6_only_obj);
386 int64_t port = 0; 388 int64_t port = 0;
387 int64_t backlog = 0; 389 int64_t backlog = 0;
388 if (!Dart_IsError(result) && 390 if (!Dart_IsError(result) &&
389 DartUtils::GetInt64Value(port_obj, &port) && 391 DartUtils::GetInt64Value(port_obj, &port) &&
390 DartUtils::GetInt64Value(backlog_obj, &backlog)) { 392 DartUtils::GetInt64Value(backlog_obj, &backlog)) {
391 intptr_t socket = ServerSocket::CreateBindListen(addr, port, backlog); 393 intptr_t socket = ServerSocket::CreateBindListen(
394 addr, port, backlog, v6_only);
392 OSError error; 395 OSError error;
393 Dart_TypedDataReleaseData(host_obj); 396 Dart_TypedDataReleaseData(host_obj);
394 if (socket >= 0) { 397 if (socket >= 0) {
395 Dart_Handle err = Socket::SetSocketIdNativeField(socket_obj, socket); 398 Dart_Handle err = Socket::SetSocketIdNativeField(socket_obj, socket);
396 if (Dart_IsError(err)) Dart_PropagateError(err); 399 if (Dart_IsError(err)) Dart_PropagateError(err);
397 Dart_SetReturnValue(args, Dart_True()); 400 Dart_SetReturnValue(args, Dart_True());
398 } else { 401 } else {
399 if (socket == -5) { 402 if (socket == -5) {
400 OSError os_error(-1, "Invalid host", OSError::kUnknown); 403 OSError os_error(-1, "Invalid host", OSError::kUnknown);
401 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); 404 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id); 577 return Dart_SetNativeInstanceField(socket, kSocketIdNativeField, id);
575 } 578 }
576 579
577 580
578 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) { 581 Dart_Handle Socket::GetSocketIdNativeField(Dart_Handle socket, intptr_t* id) {
579 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id); 582 return Dart_GetNativeInstanceField(socket, kSocketIdNativeField, id);
580 } 583 }
581 584
582 } // namespace bin 585 } // namespace bin
583 } // namespace dart 586 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | runtime/bin/socket_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698