| 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 // Cast to/from int to work-around Android bug: | 180 in_addr_t s_addr = inet_addr(host); |
| 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)))); | |
| 186 if (s_addr == INADDR_NONE) { | 181 if (s_addr == INADDR_NONE) { |
| 187 return -5; | 182 return -5; |
| 188 } | 183 } |
| 189 | 184 |
| 190 fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0)); | 185 fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0)); |
| 191 if (fd < 0) { | 186 if (fd < 0) { |
| 192 fprintf(stderr, "Error CreateBind: %s\n", strerror(errno)); | 187 fprintf(stderr, "Error CreateBind: %s\n", strerror(errno)); |
| 193 return -1; | 188 return -1; |
| 194 } | 189 } |
| 195 | 190 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // error. We got woken up from the poll on the listening socket, | 237 // error. We got woken up from the poll on the listening socket, |
| 243 // but there is no connection ready to be accepted. | 238 // but there is no connection ready to be accepted. |
| 244 ASSERT(kTemporaryFailure != -1); | 239 ASSERT(kTemporaryFailure != -1); |
| 245 socket = kTemporaryFailure; | 240 socket = kTemporaryFailure; |
| 246 } | 241 } |
| 247 } else { | 242 } else { |
| 248 FDUtils::SetNonBlocking(socket); | 243 FDUtils::SetNonBlocking(socket); |
| 249 } | 244 } |
| 250 return socket; | 245 return socket; |
| 251 } | 246 } |
| OLD | NEW |