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 |
| 10 #include "platform/globals.h" |
9 #include "platform/thread.h" | 11 #include "platform/thread.h" |
10 #include "platform/utils.h" | 12 #include "platform/utils.h" |
11 | 13 |
12 #include "include/dart_api.h" | 14 #include "include/dart_api.h" |
13 | 15 |
14 dart::Mutex Socket::mutex_; | 16 dart::Mutex Socket::mutex_; |
15 int Socket::service_ports_size_ = 0; | 17 int Socket::service_ports_size_ = 0; |
16 Dart_Port* Socket::service_ports_ = NULL; | 18 Dart_Port* Socket::service_ports_ = NULL; |
17 int Socket::service_ports_index_ = 0; | 19 int Socket::service_ports_index_ = 0; |
18 | 20 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 155 } |
154 | 156 |
155 | 157 |
156 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) { | 158 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) { |
157 Dart_EnterScope(); | 159 Dart_EnterScope(); |
158 intptr_t socket = | 160 intptr_t socket = |
159 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 161 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
160 DartUtils::kIdFieldName); | 162 DartUtils::kIdFieldName); |
161 OSError os_error; | 163 OSError os_error; |
162 intptr_t port = 0; | 164 intptr_t port = 0; |
163 char host[DART_INET_ADDRSTRLEN]; | 165 char host[INET_ADDRSTRLEN]; |
164 if (Socket::GetRemotePeer(socket, host, &port)) { | 166 if (Socket::GetRemotePeer(socket, host, &port)) { |
165 Dart_Handle list = Dart_NewList(2); | 167 Dart_Handle list = Dart_NewList(2); |
166 Dart_ListSetAt(list, 0, Dart_NewString(host)); | 168 Dart_ListSetAt(list, 0, Dart_NewString(host)); |
167 Dart_ListSetAt(list, 1, Dart_NewInteger(port)); | 169 Dart_ListSetAt(list, 1, Dart_NewInteger(port)); |
168 Dart_SetReturnValue(args, list); | 170 Dart_SetReturnValue(args, list); |
169 } else { | 171 } else { |
170 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 172 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
171 } | 173 } |
172 Dart_ExitScope(); | 174 Dart_ExitScope(); |
173 } | 175 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 Dart_EnterScope(); | 313 Dart_EnterScope(); |
312 Dart_SetReturnValue(args, Dart_Null()); | 314 Dart_SetReturnValue(args, Dart_Null()); |
313 Dart_Port service_port = Socket::GetServicePort(); | 315 Dart_Port service_port = Socket::GetServicePort(); |
314 if (service_port != kIllegalPort) { | 316 if (service_port != kIllegalPort) { |
315 // Return a send port for the service port. | 317 // Return a send port for the service port. |
316 Dart_Handle send_port = Dart_NewSendPort(service_port); | 318 Dart_Handle send_port = Dart_NewSendPort(service_port); |
317 Dart_SetReturnValue(args, send_port); | 319 Dart_SetReturnValue(args, send_port); |
318 } | 320 } |
319 Dart_ExitScope(); | 321 Dart_ExitScope(); |
320 } | 322 } |
OLD | NEW |