From 7f70420991af5c20ddd9eeda8606b9d4399ff174 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Mon, 29 Apr 2019 01:13:45 -0400 Subject: [PATCH] Add getPort --- lib/src/util.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/util.cc b/lib/src/util.cc index 51fbd532..854003cc 100644 --- a/lib/src/util.cc +++ b/lib/src/util.cc @@ -1,8 +1,16 @@ #include "angel_wings.h" +#include "wings_socket.h" +using namespace wings; void Dart_WingsSocket_getPort(Dart_NativeArguments arguments) { - // TODO: Actually do something. + uint64_t ptr; + Dart_Handle pointerHandle = Dart_GetNativeArgument(arguments, 0); + HandleError(Dart_IntegerToUint64(pointerHandle, &ptr)); + + auto* socket = (WingsSocket*) ptr; + auto outHandle = Dart_NewIntegerFromUint64(socket->getInfo().port); + Dart_SetReturnValue(arguments, outHandle); } void Dart_WingsSocket_write(Dart_NativeArguments arguments)