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

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

Issue 14766003: Add v6Only named argument to ServerSocket and etc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge Created 7 years, 7 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
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 i++; 200 i++;
201 } 201 }
202 } 202 }
203 freeaddrinfo(info); 203 freeaddrinfo(info);
204 return addresses; 204 return addresses;
205 } 205 }
206 206
207 207
208 intptr_t ServerSocket::CreateBindListen(RawAddr addr, 208 intptr_t ServerSocket::CreateBindListen(RawAddr addr,
209 intptr_t port, 209 intptr_t port,
210 intptr_t backlog) { 210 intptr_t backlog,
211 bool v6_only) {
211 intptr_t fd; 212 intptr_t fd;
212 213
213 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 214 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0));
214 if (fd < 0) return -1; 215 if (fd < 0) return -1;
215 216
216 FDUtils::SetCloseOnExec(fd); 217 FDUtils::SetCloseOnExec(fd);
217 218
218 int optval = 1; 219 int optval = 1;
219 VOID_TEMP_FAILURE_RETRY( 220 VOID_TEMP_FAILURE_RETRY(
220 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); 221 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)));
221 222
222 if (addr.ss.ss_family == AF_INET6) { 223 if (addr.ss.ss_family == AF_INET6) {
223 optval = 0; 224 optval = v6_only ? 1 : 0;
224 VOID_TEMP_FAILURE_RETRY( 225 VOID_TEMP_FAILURE_RETRY(
225 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); 226 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval)));
226 } 227 }
227 228
228 SocketAddress::SetAddrPort(&addr, port); 229 SocketAddress::SetAddrPort(&addr, port);
229 if (TEMP_FAILURE_RETRY( 230 if (TEMP_FAILURE_RETRY(
230 bind(fd, 231 bind(fd,
231 &addr.addr, 232 &addr.addr,
232 SocketAddress::GetAddrLength(addr))) < 0) { 233 SocketAddress::GetAddrLength(addr))) < 0) {
233 VOID_TEMP_FAILURE_RETRY(close(fd)); 234 VOID_TEMP_FAILURE_RETRY(close(fd));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 IPPROTO_TCP, 293 IPPROTO_TCP,
293 TCP_NODELAY, 294 TCP_NODELAY,
294 reinterpret_cast<char *>(&on), 295 reinterpret_cast<char *>(&on),
295 sizeof(on))) == 0; 296 sizeof(on))) == 0;
296 } 297 }
297 298
298 } // namespace bin 299 } // namespace bin
299 } // namespace dart 300 } // namespace dart
300 301
301 #endif // defined(TARGET_OS_MACOS) 302 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698