Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: runtime/bin/socket.cc

Issue 2205913003: Better error-message when bind fails. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add android support. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "bin/socket.h" 7 #include "bin/socket.h"
8 8
9 #include "bin/dartutils.h" 9 #include "bin/dartutils.h"
10 #include "bin/io_buffer.h" 10 #include "bin/io_buffer.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 intptr_t socket = Socket::CreateBindConnect(addr, sourceAddr); 227 intptr_t socket = Socket::CreateBindConnect(addr, sourceAddr);
228 OSError error; 228 OSError error;
229 if (socket >= 0) { 229 if (socket >= 0) {
230 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket); 230 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket);
231 Dart_SetReturnValue(args, Dart_True()); 231 Dart_SetReturnValue(args, Dart_True());
232 } else { 232 } else {
233 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); 233 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error));
234 } 234 }
235 } 235 }
236 236
237 void FUNCTION_NAME(Socket_IsBindError)(Dart_NativeArguments args) {
238 intptr_t error_number =
239 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
240 bool is_bind_error = Socket::IsBindError(error_number);
241 Dart_SetReturnValue(args, is_bind_error ? Dart_True() : Dart_False());
242 }
237 243
238 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) { 244 void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) {
239 RawAddr addr; 245 RawAddr addr;
240 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr); 246 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
241 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2); 247 Dart_Handle port_arg = Dart_GetNativeArgument(args, 2);
242 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535); 248 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535);
243 SocketAddress::SetAddrPort(&addr, port); 249 SocketAddress::SetAddrPort(&addr, port);
244 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); 250 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
245 intptr_t socket = Socket::CreateBindDatagram(addr, reuse_addr); 251 intptr_t socket = Socket::CreateBindDatagram(addr, reuse_addr);
246 if (socket >= 0) { 252 if (socket >= 0) {
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 if (Dart_IsError(err)) { 883 if (Dart_IsError(err)) {
878 Dart_PropagateError(err); 884 Dart_PropagateError(err);
879 } 885 }
880 return socket; 886 return socket;
881 } 887 }
882 888
883 } // namespace bin 889 } // namespace bin
884 } // namespace dart 890 } // namespace dart
885 891
886 #endif // !defined(DART_IO_DISABLED) 892 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698