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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "bin/socket.h" | 7 #include "bin/socket.h" |
8 | 8 |
9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
10 #include "bin/io_buffer.h" | 10 #include "bin/io_buffer.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 intptr_t socket = Socket::CreateBindConnect(addr, sourceAddr); | 227 intptr_t socket = Socket::CreateBindConnect(addr, sourceAddr); |
228 OSError error; | 228 OSError error; |
229 if (socket >= 0) { | 229 if (socket >= 0) { |
230 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); | 230 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); |
231 Dart_SetReturnValue(args, Dart_True()); | 231 Dart_SetReturnValue(args, Dart_True()); |
232 } else { | 232 } else { |
233 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); | 233 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 void FUNCTION_NAME(Socket_IsBindError)(Dart_NativeArguments args) { | |
238 intptr_t error_number = | |
239 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0)); | |
240 bool is_bind_error = Socket::IsBindError(error_number); | |
241 Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False()); | |
242 } | |
243 | 237 |
244 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { | 238 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { |
245 RawAddr addr; | 239 RawAddr addr; |
246 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); | 240 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); |
247 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); | 241 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); |
248 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); | 242 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); |
249 SocketAddress::SetAddrPort(&addr, port); | 243 SocketAddress::SetAddrPort(&addr, port); |
250 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); | 244 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); |
251 intptr_t socket = Socket::CreateBindDatagram(addr, reuse_addr); | 245 intptr_t socket = Socket::CreateBindDatagram(addr, reuse_addr); |
252 if (socket >= 0) { | 246 if (socket >= 0) { |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 if (Dart_IsError(err)) { | 877 if (Dart_IsError(err)) { |
884 Dart_PropagateError(err); | 878 Dart_PropagateError(err); |
885 } | 879 } |
886 return socket; | 880 return socket; |
887 } | 881 } |
888 | 882 |
889 } // namespace bin | 883 } // namespace bin |
890 } // namespace dart | 884 } // namespace dart |
891 | 885 |
892 #endif // !defined(DART_IO_DISABLED) | 886 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |