| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 return buffer; | 169 return buffer; |
| 170 } | 170 } |
| 171 | 171 |
| 172 | 172 |
| 173 intptr_t ServerSocket::CreateBindListen(const char* host, | 173 intptr_t ServerSocket::CreateBindListen(const char* host, |
| 174 intptr_t port, | 174 intptr_t port, |
| 175 intptr_t backlog) { | 175 intptr_t backlog) { |
| 176 intptr_t fd; | 176 intptr_t fd; |
| 177 struct sockaddr_in server_address; | 177 struct sockaddr_in server_address; |
| 178 | 178 |
| 179 in_addr_t s_addr = TEMP_FAILURE_RETRY(inet_addr(host)); | 179 in_addr_t s_addr = inet_addr(host); |
| 180 if (s_addr == INADDR_NONE) { | 180 if (s_addr == INADDR_NONE) { |
| 181 return -5; | 181 return -5; |
| 182 } | 182 } |
| 183 | 183 |
| 184 fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0)); | 184 fd = TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_STREAM, 0)); |
| 185 if (fd < 0) { | 185 if (fd < 0) { |
| 186 fprintf(stderr, "Error CreateBind: %s\n", strerror(errno)); | 186 fprintf(stderr, "Error CreateBind: %s\n", strerror(errno)); |
| 187 return -1; | 187 return -1; |
| 188 } | 188 } |
| 189 | 189 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // error. We got woken up from the poll on the listening socket, | 236 // error. We got woken up from the poll on the listening socket, |
| 237 // but there is no connection ready to be accepted. | 237 // but there is no connection ready to be accepted. |
| 238 ASSERT(kTemporaryFailure != -1); | 238 ASSERT(kTemporaryFailure != -1); |
| 239 socket = kTemporaryFailure; | 239 socket = kTemporaryFailure; |
| 240 } | 240 } |
| 241 } else { | 241 } else { |
| 242 FDUtils::SetNonBlocking(socket); | 242 FDUtils::SetNonBlocking(socket); |
| 243 } | 243 } |
| 244 return socket; | 244 return socket; |
| 245 } | 245 } |
| OLD | NEW |