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

Side by Side Diff: runtime/bin/socket_linux.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.cc ('k') | runtime/bin/socket_macos.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 Linux. 19 // Nothing to do on Linux.
18 return true; 20 return true;
19 } 21 }
20 22
21 23
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 int len = sizeof(errno); 134 int len = sizeof(errno);
133 getsockopt(fd, 135 getsockopt(fd,
134 SOL_SOCKET, 136 SOL_SOCKET,
135 SO_ERROR, 137 SO_ERROR,
136 &errno, 138 &errno,
137 reinterpret_cast<socklen_t*>(&len)); 139 reinterpret_cast<socklen_t*>(&len));
138 os_error->SetCodeAndMessage(OSError::kSystem, errno); 140 os_error->SetCodeAndMessage(OSError::kSystem, errno);
139 } 141 }
140 142
141 143
144 int Socket::GetType(intptr_t fd) {
145 struct stat buf;
146 if (isatty(fd)) return File::kTerminal;
147 int result = fstat(fd, &buf);
148 if (result == -1) return -1;
149 if (S_ISFIFO(buf.st_mode)) return File::kPipe;
150 if (S_ISREG(buf.st_mode)) return File::kFile;
151 return File::kOther;
152 }
153
154
142 intptr_t Socket::GetStdioHandle(int num) { 155 intptr_t Socket::GetStdioHandle(int num) {
143 return static_cast<intptr_t>(num); 156 return static_cast<intptr_t>(num);
144 } 157 }
145 158
146 159
147 const char* Socket::LookupIPv4Address(char* host, OSError** os_error) { 160 const char* Socket::LookupIPv4Address(char* host, OSError** os_error) {
148 // Perform a name lookup for an IPv4 address. 161 // Perform a name lookup for an IPv4 address.
149 struct addrinfo hints; 162 struct addrinfo hints;
150 memset(&hints, 0, sizeof(hints)); 163 memset(&hints, 0, sizeof(hints));
151 hints.ai_family = AF_INET; 164 hints.ai_family = AF_INET;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // error. We got woken up from the poll on the listening socket, 257 // error. We got woken up from the poll on the listening socket,
245 // but there is no connection ready to be accepted. 258 // but there is no connection ready to be accepted.
246 ASSERT(kTemporaryFailure != -1); 259 ASSERT(kTemporaryFailure != -1);
247 socket = kTemporaryFailure; 260 socket = kTemporaryFailure;
248 } 261 }
249 } else { 262 } else {
250 FDUtils::SetNonBlocking(socket); 263 FDUtils::SetNonBlocking(socket);
251 } 264 }
252 return socket; 265 return socket;
253 } 266 }
OLDNEW
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/bin/socket_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698