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/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/socket.h" | 8 #include "bin/socket.h" |
9 #include "bin/thread.h" | 9 #include "bin/thread.h" |
10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 OSError error; | 50 OSError error; |
51 if (socket >= 0) { | 51 if (socket >= 0) { |
52 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); | 52 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); |
53 Dart_SetReturnValue(args, Dart_True()); | 53 Dart_SetReturnValue(args, Dart_True()); |
54 } else { | 54 } else { |
55 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); | 55 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 | 59 |
| 60 void FUNCTION_NAME(Socket_CreateBindConnect)(Dart_NativeArguments args) { |
| 61 RawAddr addr; |
| 62 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); |
| 63 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); |
| 64 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); |
| 65 RawAddr sourceAddr; |
| 66 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 3), &sourceAddr); |
| 67 intptr_t socket = Socket::CreateBindConnect( |
| 68 addr, static_cast<intptr_t>(port), sourceAddr); |
| 69 OSError error; |
| 70 if (socket >= 0) { |
| 71 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); |
| 72 Dart_SetReturnValue(args, Dart_True()); |
| 73 } else { |
| 74 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
| 75 } |
| 76 } |
| 77 |
| 78 |
60 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { | 79 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { |
61 RawAddr addr; | 80 RawAddr addr; |
62 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); | 81 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); |
63 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); | 82 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); |
64 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); | 83 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); |
65 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); | 84 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); |
66 intptr_t socket = Socket::CreateBindDatagram(&addr, | 85 intptr_t socket = Socket::CreateBindDatagram(&addr, |
67 static_cast<intptr_t>(port), | 86 static_cast<intptr_t>(port), |
68 reuse_addr); | 87 reuse_addr); |
69 if (socket >= 0) { | 88 if (socket >= 0) { |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { | 707 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { |
689 intptr_t socket = 0; | 708 intptr_t socket = 0; |
690 Dart_Handle err = | 709 Dart_Handle err = |
691 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); | 710 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); |
692 if (Dart_IsError(err)) Dart_PropagateError(err); | 711 if (Dart_IsError(err)) Dart_PropagateError(err); |
693 return socket; | 712 return socket; |
694 } | 713 } |
695 | 714 |
696 } // namespace bin | 715 } // namespace bin |
697 } // namespace dart | 716 } // namespace dart |
OLD | NEW |