| 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 | 9 |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 DartUtils::GetInt64Value(port_obj, &port) && | 231 DartUtils::GetInt64Value(port_obj, &port) && |
| 232 DartUtils::GetInt64Value(backlog_obj, &backlog)) { | 232 DartUtils::GetInt64Value(backlog_obj, &backlog)) { |
| 233 const char* bind_address = DartUtils::GetStringValue(bind_address_obj); | 233 const char* bind_address = DartUtils::GetStringValue(bind_address_obj); |
| 234 intptr_t socket = | 234 intptr_t socket = |
| 235 ServerSocket::CreateBindListen(bind_address, port, backlog); | 235 ServerSocket::CreateBindListen(bind_address, port, backlog); |
| 236 if (socket >= 0) { | 236 if (socket >= 0) { |
| 237 DartUtils::SetIntegerField( | 237 DartUtils::SetIntegerField( |
| 238 socket_obj, DartUtils::kIdFieldName, socket); | 238 socket_obj, DartUtils::kIdFieldName, socket); |
| 239 Dart_SetReturnValue(args, Dart_True()); | 239 Dart_SetReturnValue(args, Dart_True()); |
| 240 } else { | 240 } else { |
| 241 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 241 if (socket == -5) { |
| 242 OSError os_error(-1, "Invalid host", OSError::kUnknown); |
| 243 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error)); |
| 244 } else { |
| 245 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 246 } |
| 242 } | 247 } |
| 243 } else { | 248 } else { |
| 244 OSError os_error(-1, "Invalid argument", OSError::kUnknown); | 249 OSError os_error(-1, "Invalid argument", OSError::kUnknown); |
| 245 Dart_Handle err = DartUtils::NewDartOSError(&os_error); | 250 Dart_Handle err = DartUtils::NewDartOSError(&os_error); |
| 246 if (Dart_IsError(err)) Dart_PropagateError(err); | 251 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 247 Dart_SetReturnValue(args, err); | 252 Dart_SetReturnValue(args, err); |
| 248 } | 253 } |
| 249 Dart_ExitScope(); | 254 Dart_ExitScope(); |
| 250 } | 255 } |
| 251 | 256 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 Dart_EnterScope(); | 346 Dart_EnterScope(); |
| 342 Dart_SetReturnValue(args, Dart_Null()); | 347 Dart_SetReturnValue(args, Dart_Null()); |
| 343 Dart_Port service_port = Socket::GetServicePort(); | 348 Dart_Port service_port = Socket::GetServicePort(); |
| 344 if (service_port != ILLEGAL_PORT) { | 349 if (service_port != ILLEGAL_PORT) { |
| 345 // Return a send port for the service port. | 350 // Return a send port for the service port. |
| 346 Dart_Handle send_port = Dart_NewSendPort(service_port); | 351 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 347 Dart_SetReturnValue(args, send_port); | 352 Dart_SetReturnValue(args, send_port); |
| 348 } | 353 } |
| 349 Dart_ExitScope(); | 354 Dart_ExitScope(); |
| 350 } | 355 } |
| OLD | NEW |