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

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

Issue 11773041: Add function for finding what a InputStream or OutputStream is attached to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months 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') | runtime/bin/stdio_patch.dart » ('j') | 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) 2012, 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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "bin/eventhandler.h" 6 #include "bin/eventhandler.h"
7 #include "bin/file.h"
7 #include "bin/log.h" 8 #include "bin/log.h"
8 #include "bin/socket.h" 9 #include "bin/socket.h"
9 10
10 bool Socket::Initialize() { 11 bool Socket::Initialize() {
11 int err; 12 int err;
12 WSADATA winsock_data; 13 WSADATA winsock_data;
13 WORD version_requested = MAKEWORD(1, 0); 14 WORD version_requested = MAKEWORD(1, 0);
14 err = WSAStartup(version_requested, &winsock_data); 15 err = WSAStartup(version_requested, &winsock_data);
15 if (err != 0) { 16 if (err != 0) {
16 Log::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError()); 17 Log::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return reinterpret_cast<intptr_t>(client_socket); 132 return reinterpret_cast<intptr_t>(client_socket);
132 } 133 }
133 134
134 135
135 void Socket::GetError(intptr_t fd, OSError* os_error) { 136 void Socket::GetError(intptr_t fd, OSError* os_error) {
136 Handle* handle = reinterpret_cast<Handle*>(fd); 137 Handle* handle = reinterpret_cast<Handle*>(fd);
137 os_error->SetCodeAndMessage(OSError::kSystem, handle->last_error()); 138 os_error->SetCodeAndMessage(OSError::kSystem, handle->last_error());
138 } 139 }
139 140
140 141
142 int Socket::GetType(intptr_t fd) {
143 Handle* handle = reinterpret_cast<Handle*>(fd);
144 switch (GetFileType(handle->handle())) {
145 case FILE_TYPE_CHAR: return File::kTerminal;
146 case FILE_TYPE_PIPE: return File::kPipe;
147 case FILE_TYPE_DISK: return File::kFile;
148 default: return GetLastError == NO_ERROR ? File::kOther : -1;
149 }
150 }
151
152
141 intptr_t Socket::GetStdioHandle(int num) { 153 intptr_t Socket::GetStdioHandle(int num) {
142 HANDLE handle; 154 HANDLE handle;
143 switch (num) { 155 switch (num) {
144 case 0: 156 case 0:
145 handle = GetStdHandle(STD_INPUT_HANDLE); 157 handle = GetStdHandle(STD_INPUT_HANDLE);
146 break; 158 break;
147 case 1: 159 case 1:
148 handle = GetStdHandle(STD_OUTPUT_HANDLE); 160 handle = GetStdHandle(STD_OUTPUT_HANDLE);
149 break; 161 break;
150 case 2: 162 case 2:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (status == SOCKET_ERROR) { 266 if (status == SOCKET_ERROR) {
255 DWORD rc = WSAGetLastError(); 267 DWORD rc = WSAGetLastError();
256 closesocket(s); 268 closesocket(s);
257 SetLastError(rc); 269 SetLastError(rc);
258 return -1; 270 return -1;
259 } 271 }
260 272
261 ListenSocket* listen_socket = new ListenSocket(s); 273 ListenSocket* listen_socket = new ListenSocket(s);
262 return reinterpret_cast<intptr_t>(listen_socket); 274 return reinterpret_cast<intptr_t>(listen_socket);
263 } 275 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | runtime/bin/stdio_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698