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

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

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | « dart/runtime/bin/socket.cc ('k') | dart/runtime/bin/socket_linux.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) 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
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const int kBufferSize = 1024; 129 const int kBufferSize = 1024;
130 char error_message[kBufferSize]; 130 char error_message[kBufferSize];
131 strerror_r(errno, error_message, kBufferSize); 131 strerror_r(errno, error_message, kBufferSize);
132 Log::PrintErr("Error getsockname: %s\n", error_message); 132 Log::PrintErr("Error getsockname: %s\n", error_message);
133 return 0; 133 return 0;
134 } 134 }
135 return SocketAddress::GetAddrPort(&raw); 135 return SocketAddress::GetAddrPort(&raw);
136 } 136 }
137 137
138 138
139 bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) { 139 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) {
140 ASSERT(fd >= 0); 140 ASSERT(fd >= 0);
141 RawAddr raw; 141 RawAddr raw;
142 socklen_t size = sizeof(raw); 142 socklen_t size = sizeof(raw);
143 if (TEMP_FAILURE_RETRY( 143 if (TEMP_FAILURE_RETRY(
144 getpeername(fd, 144 getpeername(fd,
145 &raw.addr, 145 &raw.addr,
146 &size))) { 146 &size))) {
147 const int kBufferSize = 1024; 147 const int kBufferSize = 1024;
148 char error_message[kBufferSize]; 148 char error_message[kBufferSize];
149 strerror_r(errno, error_message, kBufferSize); 149 strerror_r(errno, error_message, kBufferSize);
150 Log::PrintErr("Error getpeername: %s\n", error_message); 150 Log::PrintErr("Error getpeername: %s\n", error_message);
151 return false; 151 return NULL;
152 }
153 if (TEMP_FAILURE_RETRY(getnameinfo(&raw.addr,
154 size,
155 host,
156 INET6_ADDRSTRLEN,
157 NULL,
158 0,
159 NI_NUMERICHOST)) != 0) {
160 const int kBufferSize = 1024;
161 char error_message[kBufferSize];
162 strerror_r(errno, error_message, kBufferSize);
163 Log::PrintErr("Error getnameinfo: %s\n", error_message);
164 return false;
165 } 152 }
166 *port = SocketAddress::GetAddrPort(&raw); 153 *port = SocketAddress::GetAddrPort(&raw);
167 return true; 154 return new SocketAddress(&raw.addr);
168 } 155 }
169 156
170 157
171 void Socket::GetError(intptr_t fd, OSError* os_error) { 158 void Socket::GetError(intptr_t fd, OSError* os_error) {
172 int errorNumber; 159 int errorNumber;
173 socklen_t len = sizeof(errorNumber); 160 socklen_t len = sizeof(errorNumber);
174 getsockopt(fd, 161 getsockopt(fd,
175 SOL_SOCKET, 162 SOL_SOCKET,
176 SO_ERROR, 163 SO_ERROR,
177 reinterpret_cast<void*>(&errorNumber), 164 reinterpret_cast<void*>(&errorNumber),
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 IPPROTO_TCP, 362 IPPROTO_TCP,
376 TCP_NODELAY, 363 TCP_NODELAY,
377 reinterpret_cast<char *>(&on), 364 reinterpret_cast<char *>(&on),
378 sizeof(on))) == 0; 365 sizeof(on))) == 0;
379 } 366 }
380 367
381 } // namespace bin 368 } // namespace bin
382 } // namespace dart 369 } // namespace dart
383 370
384 #endif // defined(TARGET_OS_ANDROID) 371 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « dart/runtime/bin/socket.cc ('k') | dart/runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698