net/SocketDescriptor: add Duplicate() method

The the Duplicate() method we inherited from class FileDescriptor
returns a UniqueFileDescriptor, but we really want to return a
UniqueSocketDescriptor.
This commit is contained in:
Max Kellermann
2024-08-02 16:52:17 +02:00
committed by Max Kellermann
parent dbb2b29271
commit 314667259e
3 changed files with 16 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
#include "StaticSocketAddress.hxx"
#include "IPv4Address.hxx"
#include "IPv6Address.hxx"
#include "UniqueSocketDescriptor.hxx"
#ifdef _WIN32
#include <ws2tcpip.h>
@@ -243,7 +244,15 @@ SocketDescriptor::SetNonBlocking() const noexcept
return ioctlsocket(fd, FIONBIO, &val) == 0;
}
#endif
#else
UniqueSocketDescriptor
SocketDescriptor::Duplicate() const noexcept
{
return UniqueSocketDescriptor{FileDescriptor::Duplicate()};
}
#endif // !_WIN32
bool
SocketDescriptor::SetOption(int level, int name,