| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); | 90 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); |
| 91 RawAddr raw; | 91 RawAddr raw; |
| 92 socklen_t size = sizeof(raw); | 92 socklen_t size = sizeof(raw); |
| 93 if (getpeername(socket_handle->socket(), | 93 if (getpeername(socket_handle->socket(), |
| 94 &raw.addr, | 94 &raw.addr, |
| 95 &size)) { | 95 &size)) { |
| 96 Log::PrintErr("Error getpeername: %d\n", WSAGetLastError()); | 96 Log::PrintErr("Error getpeername: %d\n", WSAGetLastError()); |
| 97 return NULL; | 97 return NULL; |
| 98 } | 98 } |
| 99 *port = SocketAddress::GetAddrPort(&raw); | 99 *port = SocketAddress::GetAddrPort(&raw); |
| 100 // Clear the port before calling WSAAddressToString as WSAAddressToString |
| 101 // includes the port in the formatted string. |
| 102 SocketAddress::SetAddrPort(&raw, 0); |
| 100 return new SocketAddress(&raw.addr); | 103 return new SocketAddress(&raw.addr); |
| 101 } | 104 } |
| 102 | 105 |
| 103 | 106 |
| 104 intptr_t Socket::Create(RawAddr addr) { | 107 intptr_t Socket::Create(RawAddr addr) { |
| 105 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0); | 108 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0); |
| 106 if (s == INVALID_SOCKET) { | 109 if (s == INVALID_SOCKET) { |
| 107 return -1; | 110 return -1; |
| 108 } | 111 } |
| 109 | 112 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 IPPROTO_TCP, | 429 IPPROTO_TCP, |
| 427 TCP_NODELAY, | 430 TCP_NODELAY, |
| 428 reinterpret_cast<char *>(&on), | 431 reinterpret_cast<char *>(&on), |
| 429 sizeof(on)) == 0; | 432 sizeof(on)) == 0; |
| 430 } | 433 } |
| 431 | 434 |
| 432 } // namespace bin | 435 } // namespace bin |
| 433 } // namespace dart | 436 } // namespace dart |
| 434 | 437 |
| 435 #endif // defined(TARGET_OS_WINDOWS) | 438 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |