| 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 "platform/globals.h" | 7 #include "platform/globals.h" |
| 8 #if defined(HOST_OS_WINDOWS) | 8 #if defined(HOST_OS_WINDOWS) |
| 9 | 9 |
| 10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 WORD version_requested = MAKEWORD(2, 2); | 75 WORD version_requested = MAKEWORD(2, 2); |
| 76 err = WSAStartup(version_requested, &winsock_data); | 76 err = WSAStartup(version_requested, &winsock_data); |
| 77 if (err == 0) { | 77 if (err == 0) { |
| 78 socket_initialized = true; | 78 socket_initialized = true; |
| 79 } else { | 79 } else { |
| 80 Log::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError()); | 80 Log::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError()); |
| 81 } | 81 } |
| 82 return (err == 0); | 82 return (err == 0); |
| 83 } | 83 } |
| 84 | 84 |
| 85 |
| 85 intptr_t Socket::Available(intptr_t fd) { | 86 intptr_t Socket::Available(intptr_t fd) { |
| 86 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); | 87 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); |
| 87 return client_socket->Available(); | 88 return client_socket->Available(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 | 91 |
| 91 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { | 92 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { |
| 92 Handle* handle = reinterpret_cast<Handle*>(fd); | 93 Handle* handle = reinterpret_cast<Handle*>(fd); |
| 93 return handle->Read(buffer, num_bytes); | 94 return handle->Read(buffer, num_bytes); |
| 94 } | 95 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 282 |
| 282 | 283 |
| 283 intptr_t Socket::GetStdioHandle(intptr_t num) { | 284 intptr_t Socket::GetStdioHandle(intptr_t num) { |
| 284 if (num != 0) { | 285 if (num != 0) { |
| 285 return -1; | 286 return -1; |
| 286 } | 287 } |
| 287 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); | 288 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); |
| 288 if (handle == INVALID_HANDLE_VALUE) { | 289 if (handle == INVALID_HANDLE_VALUE) { |
| 289 return -1; | 290 return -1; |
| 290 } | 291 } |
| 291 StdHandle* std_handle = new StdHandle(handle); | 292 StdHandle* std_handle = StdHandle::Stdin(handle); |
| 293 std_handle->Retain(); |
| 292 std_handle->MarkDoesNotSupportOverlappedIO(); | 294 std_handle->MarkDoesNotSupportOverlappedIO(); |
| 293 std_handle->EnsureInitialized(EventHandler::delegate()); | 295 std_handle->EnsureInitialized(EventHandler::delegate()); |
| 294 return reinterpret_cast<intptr_t>(std_handle); | 296 return reinterpret_cast<intptr_t>(std_handle); |
| 295 } | 297 } |
| 296 | 298 |
| 297 | 299 |
| 298 intptr_t ServerSocket::Accept(intptr_t fd) { | 300 intptr_t ServerSocket::Accept(intptr_t fd) { |
| 299 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd); | 301 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd); |
| 300 ClientSocket* client_socket = listen_socket->Accept(); | 302 ClientSocket* client_socket = listen_socket->Accept(); |
| 301 if (client_socket != NULL) { | 303 if (client_socket != NULL) { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 return setsockopt(handle->socket(), proto, MCAST_LEAVE_GROUP, | 683 return setsockopt(handle->socket(), proto, MCAST_LEAVE_GROUP, |
| 682 reinterpret_cast<char*>(&mreq), sizeof(mreq)) == 0; | 684 reinterpret_cast<char*>(&mreq), sizeof(mreq)) == 0; |
| 683 } | 685 } |
| 684 | 686 |
| 685 } // namespace bin | 687 } // namespace bin |
| 686 } // namespace dart | 688 } // namespace dart |
| 687 | 689 |
| 688 #endif // defined(HOST_OS_WINDOWS) | 690 #endif // defined(HOST_OS_WINDOWS) |
| 689 | 691 |
| 690 #endif // !defined(DART_IO_DISABLED) | 692 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |