Skip to content

Commit

Permalink
net/UniqueSocketDescriptor: add method MoveToFileDescriptor()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Apr 4, 2024
1 parent a576008 commit 941d6b7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/net/UniqueSocketDescriptor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include "SocketDescriptor.hxx"

#ifndef _WIN32
#include "io/UniqueFileDescriptor.hxx"
#endif

#include <utility>

class StaticSocketAddress;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 941d6b7

Please sign in to comment.