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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/eventhandler.h" | 9 #include "bin/eventhandler.h" |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 ASSERT(*os_error == NULL); | 261 ASSERT(*os_error == NULL); |
262 DWORD error_code = WSAGetLastError(); | 262 DWORD error_code = WSAGetLastError(); |
263 SetLastError(error_code); | 263 SetLastError(error_code); |
264 *os_error = new OSError(); | 264 *os_error = new OSError(); |
265 return false; | 265 return false; |
266 } | 266 } |
267 return true; | 267 return true; |
268 } | 268 } |
269 | 269 |
270 | 270 |
| 271 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { |
| 272 int result; |
| 273 const wchar_t* system_address = StringUtils::Utf8ToWide(address); |
| 274 if (type == SocketAddress::TYPE_IPV4) { |
| 275 result = InetPton(AF_INET, system_address, &addr->in.sin_addr); |
| 276 } else { |
| 277 ASSERT(type == SocketAddress::TYPE_IPV6); |
| 278 result = InetPton(AF_INET6, system_address, &addr->in6.sin6_addr); |
| 279 } |
| 280 free(const_cast<wchar_t*>(system_address)); |
| 281 return result == 1; |
| 282 } |
| 283 |
| 284 |
271 AddressList<InterfaceSocketAddress>* Socket::ListInterfaces( | 285 AddressList<InterfaceSocketAddress>* Socket::ListInterfaces( |
272 int type, | 286 int type, |
273 OSError** os_error) { | 287 OSError** os_error) { |
274 Initialize(); | 288 Initialize(); |
275 | 289 |
276 ULONG size = 0; | 290 ULONG size = 0; |
277 DWORD flags = GAA_FLAG_SKIP_ANYCAST | | 291 DWORD flags = GAA_FLAG_SKIP_ANYCAST | |
278 GAA_FLAG_SKIP_MULTICAST | | 292 GAA_FLAG_SKIP_MULTICAST | |
279 GAA_FLAG_SKIP_DNS_SERVER; | 293 GAA_FLAG_SKIP_DNS_SERVER; |
280 // Query the size needed. | 294 // Query the size needed. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 IPPROTO_TCP, | 443 IPPROTO_TCP, |
430 TCP_NODELAY, | 444 TCP_NODELAY, |
431 reinterpret_cast<char *>(&on), | 445 reinterpret_cast<char *>(&on), |
432 sizeof(on)) == 0; | 446 sizeof(on)) == 0; |
433 } | 447 } |
434 | 448 |
435 } // namespace bin | 449 } // namespace bin |
436 } // namespace dart | 450 } // namespace dart |
437 | 451 |
438 #endif // defined(TARGET_OS_WINDOWS) | 452 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |