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

Side by Side Diff: runtime/bin/socket_macos.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_linux.cc ('k') | runtime/bin/socket_win.cc » ('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 <errno.h> 5 #include <errno.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/stat.h>
9 #include <unistd.h> 10 #include <unistd.h>
10 11
11 #include "bin/fdutils.h" 12 #include "bin/fdutils.h"
13 #include "bin/file.h"
12 #include "bin/log.h" 14 #include "bin/log.h"
13 #include "bin/socket.h" 15 #include "bin/socket.h"
14 16
15 17
16 bool Socket::Initialize() { 18 bool Socket::Initialize() {
17 // Nothing to do on Mac OS. 19 // Nothing to do on Mac OS.
18 return true; 20 return true;
19 } 21 }
20 22
21 23
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 int len = sizeof(errno); 130 int len = sizeof(errno);
129 getsockopt(fd, 131 getsockopt(fd,
130 SOL_SOCKET, 132 SOL_SOCKET,
131 SO_ERROR, 133 SO_ERROR,
132 &errno, 134 &errno,
133 reinterpret_cast<socklen_t*>(&len)); 135 reinterpret_cast<socklen_t*>(&len));
134 os_error->SetCodeAndMessage(OSError::kSystem, errno); 136 os_error->SetCodeAndMessage(OSError::kSystem, errno);
135 } 137 }
136 138
137 139
140 int Socket::GetType(intptr_t fd) {
141 struct stat buf;
142 if (isatty(fd)) return File::kTerminal;
143 int result = fstat(fd, &buf);
144 if (result == -1) return -1;
145 if (S_ISFIFO(buf.st_mode)) return File::kPipe;
146 if (S_ISREG(buf.st_mode)) return File::kFile;
147 return File::kOther;
148 }
149
150
138 intptr_t Socket::GetStdioHandle(int num) { 151 intptr_t Socket::GetStdioHandle(int num) {
139 return static_cast<intptr_t>(num); 152 return static_cast<intptr_t>(num);
140 } 153 }
141 154
142 155
143 const char* Socket::LookupIPv4Address(char* host, OSError** os_error) { 156 const char* Socket::LookupIPv4Address(char* host, OSError** os_error) {
144 // Perform a name lookup for an IPv4 address. 157 // Perform a name lookup for an IPv4 address.
145 struct addrinfo hints; 158 struct addrinfo hints;
146 memset(&hints, 0, sizeof(hints)); 159 memset(&hints, 0, sizeof(hints));
147 hints.ai_family = AF_INET; 160 hints.ai_family = AF_INET;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // error. We got woken up from the poll on the listening socket, 243 // error. We got woken up from the poll on the listening socket,
231 // but there is no connection ready to be accepted. 244 // but there is no connection ready to be accepted.
232 ASSERT(kTemporaryFailure != -1); 245 ASSERT(kTemporaryFailure != -1);
233 socket = kTemporaryFailure; 246 socket = kTemporaryFailure;
234 } 247 }
235 } else { 248 } else {
236 FDUtils::SetNonBlocking(socket); 249 FDUtils::SetNonBlocking(socket);
237 } 250 }
238 return socket; 251 return socket;
239 } 252 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698