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

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

Issue 15894004: dart:io | Fix a few bugs in the Android port of dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
« runtime/bin/file_android.cc ('K') | « runtime/bin/file_android.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <stdio.h> // NOLINT 9 #include <stdio.h> // NOLINT
10 #include <stdlib.h> // NOLINT 10 #include <stdlib.h> // NOLINT
11 #include <string.h> // NOLINT 11 #include <string.h> // NOLINT
12 #include <sys/stat.h> // NOLINT
12 #include <unistd.h> // NOLINT 13 #include <unistd.h> // NOLINT
13 #include <netinet/tcp.h> // NOLINT 14 #include <netinet/tcp.h> // NOLINT
14 15
16 #include "bin/fdutils.h"
17 #include "bin/file.h"
18 #include "bin/log.h"
15 #include "bin/socket.h" 19 #include "bin/socket.h"
16 #include "bin/fdutils.h"
17 #include "bin/log.h"
18 20
19 21
20 namespace dart { 22 namespace dart {
21 namespace bin { 23 namespace bin {
22 24
23 SocketAddress::SocketAddress(struct addrinfo* addrinfo) { 25 SocketAddress::SocketAddress(struct addrinfo* addrinfo) {
24 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN); 26 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
25 RawAddr* raw = reinterpret_cast<RawAddr*>(addrinfo->ai_addr); 27 RawAddr* raw = reinterpret_cast<RawAddr*>(addrinfo->ai_addr);
26 const char* result = inet_ntop(addrinfo->ai_family, 28 const char* result = inet_ntop(addrinfo->ai_family,
27 &raw->in.sin_addr, 29 &raw->in.sin_addr,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 socklen_t len = sizeof(errorNumber); 147 socklen_t len = sizeof(errorNumber);
146 getsockopt(fd, 148 getsockopt(fd,
147 SOL_SOCKET, 149 SOL_SOCKET,
148 SO_ERROR, 150 SO_ERROR,
149 reinterpret_cast<void*>(&errorNumber), 151 reinterpret_cast<void*>(&errorNumber),
150 &len); 152 &len);
151 os_error->SetCodeAndMessage(OSError::kSystem, errorNumber); 153 os_error->SetCodeAndMessage(OSError::kSystem, errorNumber);
152 } 154 }
153 155
154 156
157 int Socket::GetType(intptr_t fd) {
158 struct stat buf;
159 int result = fstat(fd, &buf);
160 if (result == -1) return -1;
161 if (S_ISCHR(buf.st_mode)) return File::kTerminal;
162 if (S_ISFIFO(buf.st_mode)) return File::kPipe;
163 if (S_ISREG(buf.st_mode)) return File::kFile;
164 return File::kOther;
165 }
166
167
155 intptr_t Socket::GetStdioHandle(int num) { 168 intptr_t Socket::GetStdioHandle(int num) {
156 return static_cast<intptr_t>(num); 169 return static_cast<intptr_t>(num);
157 } 170 }
158 171
159 172
160 SocketAddresses* Socket::LookupAddress(const char* host, 173 SocketAddresses* Socket::LookupAddress(const char* host,
161 int type, 174 int type,
162 OSError** os_error) { 175 OSError** os_error) {
163 // Perform a name lookup for a host name. 176 // Perform a name lookup for a host name.
164 struct addrinfo hints; 177 struct addrinfo hints;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 SOL_TCP, 304 SOL_TCP,
292 TCP_NODELAY, 305 TCP_NODELAY,
293 reinterpret_cast<char *>(&on), 306 reinterpret_cast<char *>(&on),
294 sizeof(on))) == 0; 307 sizeof(on))) == 0;
295 } 308 }
296 309
297 } // namespace bin 310 } // namespace bin
298 } // namespace dart 311 } // namespace dart
299 312
300 #endif // defined(TARGET_OS_ANDROID) 313 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« runtime/bin/file_android.cc ('K') | « runtime/bin/file_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698