| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 | 100 |
| 101 intptr_t Socket::GetPort(intptr_t fd) { | 101 intptr_t Socket::GetPort(intptr_t fd) { |
| 102 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket()); | 102 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket()); |
| 103 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); | 103 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); |
| 104 RawAddr raw; | 104 RawAddr raw; |
| 105 socklen_t size = sizeof(raw); | 105 socklen_t size = sizeof(raw); |
| 106 if (getsockname(socket_handle->socket(), | 106 if (getsockname(socket_handle->socket(), |
| 107 &raw.addr, | 107 &raw.addr, |
| 108 &size) == SOCKET_ERROR) { | 108 &size) == SOCKET_ERROR) { |
| 109 Log::PrintErr("Error getsockname: %d\n", WSAGetLastError()); | |
| 110 return 0; | 109 return 0; |
| 111 } | 110 } |
| 112 return SocketAddress::GetAddrPort(&raw); | 111 return SocketAddress::GetAddrPort(&raw); |
| 113 } | 112 } |
| 114 | 113 |
| 115 | 114 |
| 116 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) { | 115 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) { |
| 117 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket()); | 116 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket()); |
| 118 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); | 117 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); |
| 119 RawAddr raw; | 118 RawAddr raw; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); | 549 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); |
| 551 client_socket->Close(); | 550 client_socket->Close(); |
| 552 } | 551 } |
| 553 | 552 |
| 554 | 553 |
| 555 static bool SetBlockingHelper(intptr_t fd, bool blocking) { | 554 static bool SetBlockingHelper(intptr_t fd, bool blocking) { |
| 556 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd); | 555 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd); |
| 557 u_long iMode = blocking ? 0 : 1; | 556 u_long iMode = blocking ? 0 : 1; |
| 558 int status = ioctlsocket(handle->socket(), FIONBIO, &iMode); | 557 int status = ioctlsocket(handle->socket(), FIONBIO, &iMode); |
| 559 if (status != NO_ERROR) { | 558 if (status != NO_ERROR) { |
| 560 Log::PrintErr("ioctlsocket FIONBIO failed: %d\n", status); | |
| 561 return false; | 559 return false; |
| 562 } | 560 } |
| 563 return true; | 561 return true; |
| 564 } | 562 } |
| 565 | 563 |
| 566 | 564 |
| 567 bool Socket::SetNonBlocking(intptr_t fd) { | 565 bool Socket::SetNonBlocking(intptr_t fd) { |
| 568 return SetBlockingHelper(fd, false); | 566 return SetBlockingHelper(fd, false); |
| 569 } | 567 } |
| 570 | 568 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 proto, | 719 proto, |
| 722 MCAST_LEAVE_GROUP, | 720 MCAST_LEAVE_GROUP, |
| 723 reinterpret_cast<char *>(&mreq), | 721 reinterpret_cast<char *>(&mreq), |
| 724 sizeof(mreq)) == 0; | 722 sizeof(mreq)) == 0; |
| 725 } | 723 } |
| 726 | 724 |
| 727 } // namespace bin | 725 } // namespace bin |
| 728 } // namespace dart | 726 } // namespace dart |
| 729 | 727 |
| 730 #endif // defined(TARGET_OS_WINDOWS) | 728 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |