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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 187 } |
188 bool ok = Socket::ParseAddress(type, address, &raw); | 188 bool ok = Socket::ParseAddress(type, address, &raw); |
189 if (!ok) { | 189 if (!ok) { |
190 Dart_SetReturnValue(args, Dart_Null()); | 190 Dart_SetReturnValue(args, Dart_Null()); |
191 } else { | 191 } else { |
192 Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw)); | 192 Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw)); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 | 196 |
| 197 void FUNCTION_NAME(NetworkInterface_ListSupported)(Dart_NativeArguments args) { |
| 198 Dart_SetReturnValue(args, Dart_NewBoolean(Socket::ListInterfacesSupported())); |
| 199 } |
| 200 |
| 201 |
197 void FUNCTION_NAME(Socket_CreateConnect)(Dart_NativeArguments args) { | 202 void FUNCTION_NAME(Socket_CreateConnect)(Dart_NativeArguments args) { |
198 RawAddr addr; | 203 RawAddr addr; |
199 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); | 204 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); |
200 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); | 205 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); |
201 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); | 206 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); |
202 SocketAddress::SetAddrPort(&addr, static_cast<intptr_t>(port)); | 207 SocketAddress::SetAddrPort(&addr, static_cast<intptr_t>(port)); |
203 intptr_t socket = Socket::CreateConnect(addr); | 208 intptr_t socket = Socket::CreateConnect(addr); |
204 OSError error; | 209 OSError error; |
205 if (socket >= 0) { | 210 if (socket >= 0) { |
206 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); | 211 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 if (Dart_IsError(err)) { | 877 if (Dart_IsError(err)) { |
873 Dart_PropagateError(err); | 878 Dart_PropagateError(err); |
874 } | 879 } |
875 return socket; | 880 return socket; |
876 } | 881 } |
877 | 882 |
878 } // namespace bin | 883 } // namespace bin |
879 } // namespace dart | 884 } // namespace dart |
880 | 885 |
881 #endif // !defined(DART_IO_DISABLED) | 886 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |