| OLD | NEW |
| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 i++; | 188 i++; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 freeaddrinfo(info); | 191 freeaddrinfo(info); |
| 192 return addresses; | 192 return addresses; |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 intptr_t ServerSocket::CreateBindListen(RawAddr addr, | 196 intptr_t ServerSocket::CreateBindListen(RawAddr addr, |
| 197 intptr_t port, | 197 intptr_t port, |
| 198 intptr_t backlog) { | 198 intptr_t backlog, |
| 199 bool v6_only) { |
| 199 intptr_t fd; | 200 intptr_t fd; |
| 200 | 201 |
| 201 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0)); | 202 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0)); |
| 202 if (fd < 0) return -1; | 203 if (fd < 0) return -1; |
| 203 | 204 |
| 204 FDUtils::SetCloseOnExec(fd); | 205 FDUtils::SetCloseOnExec(fd); |
| 205 | 206 |
| 206 int optval = 1; | 207 int optval = 1; |
| 207 TEMP_FAILURE_RETRY( | 208 TEMP_FAILURE_RETRY( |
| 208 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); | 209 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); |
| 209 | 210 |
| 210 if (addr.ss.ss_family == AF_INET6) { | 211 if (addr.ss.ss_family == AF_INET6) { |
| 211 optval = 0; | 212 optval = v6_only ? 1 : 0; |
| 212 TEMP_FAILURE_RETRY( | 213 TEMP_FAILURE_RETRY( |
| 213 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); | 214 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); |
| 214 } | 215 } |
| 215 | 216 |
| 216 SocketAddress::SetAddrPort(&addr, port); | 217 SocketAddress::SetAddrPort(&addr, port); |
| 217 if (TEMP_FAILURE_RETRY( | 218 if (TEMP_FAILURE_RETRY( |
| 218 bind(fd, | 219 bind(fd, |
| 219 &addr.addr, | 220 &addr.addr, |
| 220 SocketAddress::GetAddrLength(addr))) < 0) { | 221 SocketAddress::GetAddrLength(addr))) < 0) { |
| 221 TEMP_FAILURE_RETRY(close(fd)); | 222 TEMP_FAILURE_RETRY(close(fd)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 SOL_TCP, | 291 SOL_TCP, |
| 291 TCP_NODELAY, | 292 TCP_NODELAY, |
| 292 reinterpret_cast<char *>(&on), | 293 reinterpret_cast<char *>(&on), |
| 293 sizeof(on))) == 0; | 294 sizeof(on))) == 0; |
| 294 } | 295 } |
| 295 | 296 |
| 296 } // namespace bin | 297 } // namespace bin |
| 297 } // namespace dart | 298 } // namespace dart |
| 298 | 299 |
| 299 #endif // defined(TARGET_OS_ANDROID) | 300 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |