diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index baa8b888cf32d6..8c5090ddf74e2f 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -139,12 +139,14 @@ void UDPWrap::New(const FunctionCallbackInfo& args) { void UDPWrap::GetFD(Local, const PropertyCallbackInfo& args) { + int fd = -1; #if !defined(_WIN32) HandleScope scope(args.GetIsolate()); UDPWrap* wrap = Unwrap(args.Holder()); - int fd = (wrap == nullptr) ? -1 : wrap->handle_.io_watcher.fd; - args.GetReturnValue().Set(fd); + if (wrap != nullptr) + uv_fileno(reinterpret_cast(&wrap->handle_), &fd); #endif + args.GetReturnValue().Set(fd); }