| 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return buffer; | 170 return buffer; |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 intptr_t ServerSocket::CreateBindListen(const char* host, | 174 intptr_t ServerSocket::CreateBindListen(const char* host, |
| 175 intptr_t port, | 175 intptr_t port, |
| 176 intptr_t backlog) { | 176 intptr_t backlog) { |
| 177 intptr_t fd; | 177 intptr_t fd; |
| 178 struct sockaddr_in server_address; | 178 struct sockaddr_in server_address; |
| 179 | 179 |
| 180 in_addr_t s_addr = TEMP_FAILURE_RETRY(inet_addr(host)); | 180 // Cast to/from int to work-around Android bug: |
| 181 // http://code.google.com/p/android/issues/detail?id=37426 |
| 182 // unistd.h TEMP_FAILURE_RETRY generates warning when used with syscall that |
| 183 // returns unsigned int. |
| 184 in_addr_t s_addr = static_cast<in_addr_t>( |
| 185 TEMP_FAILURE_RETRY(static_cast<int>(inet_addr(host)))); |
| 181 if (s_addr == INADDR_NONE) { | 186 if (s_addr == INADDR_NONE) { |
| 182 return -5; | 187 return -5; |
| 183 } | 188 } |
| 184 | 189 |
| 185 fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0)); | 190 fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0)); |
| 186 if (fd < 0) { | 191 if (fd < 0) { |
| 187 fprintf(stderr, "Error CreateBind: %s\n", strerror(errno)); | 192 fprintf(stderr, "Error CreateBind: %s\n", strerror(errno)); |
| 188 return -1; | 193 return -1; |
| 189 } | 194 } |
| 190 | 195 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // error. We got woken up from the poll on the listening socket, | 242 // error. We got woken up from the poll on the listening socket, |
| 238 // but there is no connection ready to be accepted. | 243 // but there is no connection ready to be accepted. |
| 239 ASSERT(kTemporaryFailure != -1); | 244 ASSERT(kTemporaryFailure != -1); |
| 240 socket = kTemporaryFailure; | 245 socket = kTemporaryFailure; |
| 241 } | 246 } |
| 242 } else { | 247 } else { |
| 243 FDUtils::SetNonBlocking(socket); | 248 FDUtils::SetNonBlocking(socket); |
| 244 } | 249 } |
| 245 return socket; | 250 return socket; |
| 246 } | 251 } |
| OLD | NEW |