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

Side by Side Diff: dart/runtime/bin/socket_linux.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_android.cc ('k') | dart/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) 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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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_buf[kBufferSize]; 131 char error_buf[kBufferSize];
132 Log::PrintErr("Error getsockname: %s\n", 132 Log::PrintErr("Error getsockname: %s\n",
133 strerror_r(errno, error_buf, kBufferSize)); 133 strerror_r(errno, error_buf, kBufferSize));
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_buf[kBufferSize]; 149 char error_buf[kBufferSize];
150 Log::PrintErr("Error getpeername: %s\n", 150 Log::PrintErr("Error getpeername: %s\n",
151 strerror_r(errno, error_buf, kBufferSize)); 151 strerror_r(errno, error_buf, kBufferSize));
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_buf[kBufferSize];
163 Log::PrintErr("Error getnameinfo: %s\n",
164 strerror_r(errno, error_buf, kBufferSize));
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 IPPROTO_TCP, 403 IPPROTO_TCP,
417 TCP_NODELAY, 404 TCP_NODELAY,
418 reinterpret_cast<char *>(&on), 405 reinterpret_cast<char *>(&on),
419 sizeof(on))) == 0; 406 sizeof(on))) == 0;
420 } 407 }
421 408
422 } // namespace bin 409 } // namespace bin
423 } // namespace dart 410 } // namespace dart
424 411
425 #endif // defined(TARGET_OS_LINUX) 412 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « dart/runtime/bin/socket_android.cc ('k') | dart/runtime/bin/socket_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698