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

Side by Side Diff: dart/runtime/bin/socket_macos.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_linux.cc ('k') | dart/runtime/bin/socket_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) 2013, 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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const int kBufferSize = 1024; 130 const int kBufferSize = 1024;
131 char error_message[kBufferSize]; 131 char error_message[kBufferSize];
132 strerror_r(errno, error_message, kBufferSize); 132 strerror_r(errno, error_message, kBufferSize);
133 Log::PrintErr("Error getsockname: %s\n", error_message); 133 Log::PrintErr("Error getsockname: %s\n", error_message);
134 return 0; 134 return 0;
135 } 135 }
136 return SocketAddress::GetAddrPort(&raw); 136 return SocketAddress::GetAddrPort(&raw);
137 } 137 }
138 138
139 139
140 bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) { 140 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) {
141 ASSERT(fd >= 0); 141 ASSERT(fd >= 0);
142 RawAddr raw; 142 RawAddr raw;
143 socklen_t size = sizeof(raw); 143 socklen_t size = sizeof(raw);
144 if (TEMP_FAILURE_RETRY( 144 if (TEMP_FAILURE_RETRY(
145 getpeername(fd, 145 getpeername(fd,
146 &raw.addr, 146 &raw.addr,
147 &size))) { 147 &size))) {
148 const int kBufferSize = 1024; 148 const int kBufferSize = 1024;
149 char error_message[kBufferSize]; 149 char error_message[kBufferSize];
150 strerror_r(errno, error_message, kBufferSize); 150 strerror_r(errno, error_message, kBufferSize);
151 Log::PrintErr("Error getpeername: %s\n", error_message); 151 Log::PrintErr("Error getpeername: %s\n", error_message);
152 return false; 152 return NULL;
153 }
154 if (TEMP_FAILURE_RETRY(getnameinfo(&raw.addr,
155 size,
156 host,
157 INET6_ADDRSTRLEN,
158 NULL,
159 0,
160 NI_NUMERICHOST)) != 0) {
161 const int kBufferSize = 1024;
162 char error_message[kBufferSize];
163 strerror_r(errno, error_message, kBufferSize);
164 Log::PrintErr("Error getnameinfo: %s\n", error_message);
165 return false;
166 } 153 }
167 *port = SocketAddress::GetAddrPort(&raw); 154 *port = SocketAddress::GetAddrPort(&raw);
168 return true; 155 return new SocketAddress(&raw.addr);
169 } 156 }
170 157
171 158
172 void Socket::GetError(intptr_t fd, OSError* os_error) { 159 void Socket::GetError(intptr_t fd, OSError* os_error) {
173 int len = sizeof(errno); 160 int len = sizeof(errno);
174 getsockopt(fd, 161 getsockopt(fd,
175 SOL_SOCKET, 162 SOL_SOCKET,
176 SO_ERROR, 163 SO_ERROR,
177 &errno, 164 &errno,
178 reinterpret_cast<socklen_t*>(&len)); 165 reinterpret_cast<socklen_t*>(&len));
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 IPPROTO_TCP, 394 IPPROTO_TCP,
408 TCP_NODELAY, 395 TCP_NODELAY,
409 reinterpret_cast<char *>(&on), 396 reinterpret_cast<char *>(&on),
410 sizeof(on))) == 0; 397 sizeof(on))) == 0;
411 } 398 }
412 399
413 } // namespace bin 400 } // namespace bin
414 } // namespace dart 401 } // namespace dart
415 402
416 #endif // defined(TARGET_OS_MACOS) 403 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « dart/runtime/bin/socket_linux.cc ('k') | dart/runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698