diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 8c460ebac6ff22..e395ee85e0852e 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -136,12 +136,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); }