OLD | NEW |
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/isolate_data.h" | 6 #include "bin/isolate_data.h" |
7 #include "bin/socket.h" | 7 #include "bin/socket.h" |
8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
9 #include "bin/thread.h" | 9 #include "bin/thread.h" |
10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 0, | 371 0, |
372 65535); | 372 65535); |
373 int64_t backlog = DartUtils::GetInt64ValueCheckRange( | 373 int64_t backlog = DartUtils::GetInt64ValueCheckRange( |
374 Dart_GetNativeArgument(args, 3), | 374 Dart_GetNativeArgument(args, 3), |
375 0, | 375 0, |
376 65535); | 376 65535); |
377 bool v6_only = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4)); | 377 bool v6_only = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4)); |
378 intptr_t socket = ServerSocket::CreateBindListen( | 378 intptr_t socket = ServerSocket::CreateBindListen( |
379 addr, port, backlog, v6_only); | 379 addr, port, backlog, v6_only); |
380 OSError error; | 380 OSError error; |
381 if (socket >= 0) { | 381 if (socket >= 0 && ServerSocket::StartAccept(socket)) { |
382 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); | 382 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); |
383 Dart_SetReturnValue(args, Dart_True()); | 383 Dart_SetReturnValue(args, Dart_True()); |
384 } else { | 384 } else { |
385 if (socket == -5) { | 385 if (socket == -5) { |
386 OSError os_error(-1, "Invalid host", OSError::kUnknown); | 386 OSError os_error(-1, "Invalid host", OSError::kUnknown); |
387 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); | 387 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); |
388 } else { | 388 } else { |
389 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); | 389 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
390 } | 390 } |
391 } | 391 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { | 687 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { |
688 intptr_t socket = 0; | 688 intptr_t socket = 0; |
689 Dart_Handle err = | 689 Dart_Handle err = |
690 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); | 690 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); |
691 if (Dart_IsError(err)) Dart_PropagateError(err); | 691 if (Dart_IsError(err)) Dart_PropagateError(err); |
692 return socket; | 692 return socket; |
693 } | 693 } |
694 | 694 |
695 } // namespace bin | 695 } // namespace bin |
696 } // namespace dart | 696 } // namespace dart |
OLD | NEW |