Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: runtime/bin/socket_win.cc

Issue 8574002: Handle stdin/stdout/stderr on Windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments from ager@ Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 <winsock2.h> 5 #include <winsock2.h>
6 #include <ws2tcpip.h> 6 #include <ws2tcpip.h>
7 #include <mswsock.h> 7 #include <mswsock.h>
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/eventhandler.h" 10 #include "bin/eventhandler.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 fprintf(stderr, "Error CreateConnect: %d\n", WSAGetLastError()); 80 fprintf(stderr, "Error CreateConnect: %d\n", WSAGetLastError());
81 closesocket(s); 81 closesocket(s);
82 return -1; 82 return -1;
83 } 83 }
84 84
85 ClientSocket* client_socket = new ClientSocket(s); 85 ClientSocket* client_socket = new ClientSocket(s);
86 return reinterpret_cast<intptr_t>(client_socket); 86 return reinterpret_cast<intptr_t>(client_socket);
87 } 87 }
88 88
89 89
90 intptr_t Socket::GetStdioHandle(int num) {
91 HANDLE handle;
92 switch (num) {
93 case 0:
94 handle = GetStdHandle(STD_INPUT_HANDLE);
95 break;
96 case 1:
97 handle = GetStdHandle(STD_OUTPUT_HANDLE);
98 break;
99 case 2:
100 handle = GetStdHandle(STD_ERROR_HANDLE);
101 break;
102 default: UNREACHABLE();
103 }
104 if (handle == INVALID_HANDLE_VALUE) {
105 fprintf(stderr, "Error GetStdHandle: %d\n", GetLastError());
106 return -1;
107 }
108 FileHandle* file_handle = new FileHandle(handle);
109 if (file_handle == NULL) return -1;
110 file_handle->MarkDoesNotSupportOverlappedIO();
111 return reinterpret_cast<intptr_t>(file_handle);
112 }
113
114
90 intptr_t ServerSocket::Accept(intptr_t fd) { 115 intptr_t ServerSocket::Accept(intptr_t fd) {
91 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd); 116 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd);
92 ClientSocket* client_socket = listen_socket->Accept(); 117 ClientSocket* client_socket = listen_socket->Accept();
93 if (client_socket != NULL) { 118 if (client_socket != NULL) {
94 return reinterpret_cast<intptr_t>(client_socket); 119 return reinterpret_cast<intptr_t>(client_socket);
95 } else { 120 } else {
96 return -1; 121 return -1;
97 } 122 }
98 } 123 }
99 124
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 status = listen(s, backlog); 161 status = listen(s, backlog);
137 if (status == SOCKET_ERROR) { 162 if (status == SOCKET_ERROR) {
138 fprintf(stderr, "Error socket listen: %d\n", WSAGetLastError()); 163 fprintf(stderr, "Error socket listen: %d\n", WSAGetLastError());
139 closesocket(s); 164 closesocket(s);
140 return -1; 165 return -1;
141 } 166 }
142 167
143 ListenSocket* listen_socket = new ListenSocket(s); 168 ListenSocket* listen_socket = new ListenSocket(s);
144 return reinterpret_cast<intptr_t>(listen_socket); 169 return reinterpret_cast<intptr_t>(listen_socket);
145 } 170 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698