Chromium Code Reviews| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 intptr_t port = Socket::GetPort(socket); | 146 intptr_t port = Socket::GetPort(socket); |
| 147 if (port > 0) { | 147 if (port > 0) { |
| 148 Dart_SetReturnValue(args, Dart_NewInteger(port)); | 148 Dart_SetReturnValue(args, Dart_NewInteger(port)); |
| 149 } else { | 149 } else { |
| 150 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 150 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 151 } | 151 } |
| 152 Dart_ExitScope(); | 152 Dart_ExitScope(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 void FUNCTION_NAME(Socket_GetRemotePort)(Dart_NativeArguments args) { | 156 void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) { |
| 157 Dart_EnterScope(); | 157 Dart_EnterScope(); |
| 158 intptr_t socket = | 158 intptr_t socket = |
| 159 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), | 159 DartUtils::GetIntegerField(Dart_GetNativeArgument(args, 0), |
| 160 DartUtils::kIdFieldName); | 160 DartUtils::kIdFieldName); |
| 161 OSError os_error; | 161 OSError os_error; |
| 162 intptr_t port = Socket::GetRemotePort(socket); | 162 intptr_t port = 0; |
| 163 if (port > 0) { | 163 const char *host = NULL; |
|
Søren Gjesse
2012/04/10 11:32:41
How about
char host[INET_ADDRSTRLEN];
here? Then
| |
| 164 Dart_SetReturnValue(args, Dart_NewInteger(port)); | 164 if (Socket::GetRemotePeer(socket, &host, &port)) { |
| 165 Dart_Handle list = Dart_NewList(2); | |
| 166 Dart_ListSetAt(list, 0, Dart_NewString(host)); | |
| 167 Dart_ListSetAt(list, 1, Dart_NewInteger(port)); | |
| 168 Dart_SetReturnValue(args, list); | |
| 169 delete[] host; | |
| 165 } else { | 170 } else { |
| 166 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 171 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 167 } | 172 } |
| 168 Dart_ExitScope(); | 173 Dart_ExitScope(); |
| 169 } | 174 } |
| 170 | 175 |
| 171 | 176 |
| 172 void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) { | 177 void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) { |
| 173 Dart_EnterScope(); | 178 Dart_EnterScope(); |
| 174 intptr_t socket = | 179 intptr_t socket = |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 Dart_EnterScope(); | 312 Dart_EnterScope(); |
| 308 Dart_SetReturnValue(args, Dart_Null()); | 313 Dart_SetReturnValue(args, Dart_Null()); |
| 309 Dart_Port service_port = Socket::GetServicePort(); | 314 Dart_Port service_port = Socket::GetServicePort(); |
| 310 if (service_port != kIllegalPort) { | 315 if (service_port != kIllegalPort) { |
| 311 // Return a send port for the service port. | 316 // Return a send port for the service port. |
| 312 Dart_Handle send_port = Dart_NewSendPort(service_port); | 317 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 313 Dart_SetReturnValue(args, send_port); | 318 Dart_SetReturnValue(args, send_port); |
| 314 } | 319 } |
| 315 Dart_ExitScope(); | 320 Dart_ExitScope(); |
| 316 } | 321 } |
| OLD | NEW |