From 941d6b7297ffa2c13b987c619660fa46511a65d2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 20 Mar 2024 09:30:29 +0100 Subject: [PATCH] net/UniqueSocketDescriptor: add method MoveToFileDescriptor() --- src/net/UniqueSocketDescriptor.hxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/net/UniqueSocketDescriptor.hxx b/src/net/UniqueSocketDescriptor.hxx index 159f8022..4c4a6466 100644 --- a/src/net/UniqueSocketDescriptor.hxx +++ b/src/net/UniqueSocketDescriptor.hxx @@ -5,6 +5,10 @@ #include "SocketDescriptor.hxx" +#ifndef _WIN32 +#include "io/UniqueFileDescriptor.hxx" +#endif + #include class StaticSocketAddress; @@ -47,6 +51,12 @@ public: return std::exchange(*(SocketDescriptor *)this, Undefined()); } +#ifndef _WIN32 + UniqueFileDescriptor MoveToFileDescriptor() && noexcept { + return UniqueFileDescriptor{Release().ToFileDescriptor()}; + } +#endif + UniqueSocketDescriptor &operator=(UniqueSocketDescriptor &&src) noexcept { using std::swap; swap(fd, src.fd);