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 "bin/socket.h" | 5 #include "bin/socket.h" |
6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.h" |
7 #include "bin/thread.h" | 7 #include "bin/thread.h" |
8 #include "bin/utils.h" | 8 #include "bin/utils.h" |
9 #include "platform/thread.h" | 9 #include "platform/thread.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 Dart_EnterScope(); | 204 Dart_EnterScope(); |
205 intptr_t socket = | 205 intptr_t socket = |
206 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 206 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
207 DartUtils::kIdFieldName); | 207 DartUtils::kIdFieldName); |
208 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1); | 208 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1); |
209 intptr_t newSocket = ServerSocket::Accept(socket); | 209 intptr_t newSocket = ServerSocket::Accept(socket); |
210 if (newSocket >= 0) { | 210 if (newSocket >= 0) { |
211 DartUtils::SetIntegerField( | 211 DartUtils::SetIntegerField( |
212 socketobj, DartUtils::kIdFieldName, newSocket); | 212 socketobj, DartUtils::kIdFieldName, newSocket); |
213 Dart_SetReturnValue(args, Dart_True()); | 213 Dart_SetReturnValue(args, Dart_True()); |
| 214 } else if (newSocket == ServerSocket::kTemporaryFailure) { |
| 215 Dart_SetReturnValue(args, Dart_False()); |
214 } else { | 216 } else { |
215 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 217 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
216 } | 218 } |
217 Dart_ExitScope(); | 219 Dart_ExitScope(); |
218 } | 220 } |
219 | 221 |
220 | 222 |
221 static CObject* LookupRequest(const CObjectArray& request) { | 223 static CObject* LookupRequest(const CObjectArray& request) { |
222 if (request.Length() == 2 && request[1]->IsString()) { | 224 if (request.Length() == 2 && request[1]->IsString()) { |
223 CObjectString host(request[1]); | 225 CObjectString host(request[1]); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 Dart_EnterScope(); | 291 Dart_EnterScope(); |
290 Dart_SetReturnValue(args, Dart_Null()); | 292 Dart_SetReturnValue(args, Dart_Null()); |
291 Dart_Port service_port = Socket::GetServicePort(); | 293 Dart_Port service_port = Socket::GetServicePort(); |
292 if (service_port != kIllegalPort) { | 294 if (service_port != kIllegalPort) { |
293 // Return a send port for the service port. | 295 // Return a send port for the service port. |
294 Dart_Handle send_port = Dart_NewSendPort(service_port); | 296 Dart_Handle send_port = Dart_NewSendPort(service_port); |
295 Dart_SetReturnValue(args, send_port); | 297 Dart_SetReturnValue(args, send_port); |
296 } | 298 } |
297 Dart_ExitScope(); | 299 Dart_ExitScope(); |
298 } | 300 } |
OLD | NEW |