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, 1)); |
| 240 bool is_bind_error = Socket::IsBindError(error_number); |
| 241 Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False()); |
| 242 } |
237 | 243 |
238 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { | 244 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { |
239 RawAddr addr; | 245 RawAddr addr; |
240 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); | 246 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); |
241 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); | 247 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); |
242 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); | 248 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); |
243 SocketAddress::SetAddrPort(&addr, port); | 249 SocketAddress::SetAddrPort(&addr, port); |
244 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); | 250 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); |
245 intptr_t socket = Socket::CreateBindDatagram(addr, reuse_addr); | 251 intptr_t socket = Socket::CreateBindDatagram(addr, reuse_addr); |
246 if (socket >= 0) { | 252 if (socket >= 0) { |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 if (Dart_IsError(err)) { | 883 if (Dart_IsError(err)) { |
878 Dart_PropagateError(err); | 884 Dart_PropagateError(err); |
879 } | 885 } |
880 return socket; | 886 return socket; |
881 } | 887 } |
882 | 888 |
883 } // namespace bin | 889 } // namespace bin |
884 } // namespace dart | 890 } // namespace dart |
885 | 891 |
886 #endif // !defined(DART_IO_DISABLED) | 892 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |