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:
parent
dbb2b29271
commit
314667259e
|
@ -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,
|
||||
|
|
|
@ -24,6 +24,7 @@ class SocketAddress;
|
|||
class StaticSocketAddress;
|
||||
class IPv4Address;
|
||||
class IPv6Address;
|
||||
class UniqueSocketDescriptor;
|
||||
|
||||
/**
|
||||
* An OO wrapper for a Berkeley or WinSock socket descriptor.
|
||||
|
@ -137,7 +138,10 @@ public:
|
|||
|
||||
using FileDescriptor::SetNonBlocking;
|
||||
using FileDescriptor::SetBlocking;
|
||||
using FileDescriptor::Duplicate;
|
||||
|
||||
[[nodiscard]]
|
||||
UniqueSocketDescriptor Duplicate() const noexcept;
|
||||
|
||||
using FileDescriptor::CheckDuplicate;
|
||||
using FileDescriptor::Close;
|
||||
#else
|
||||
|
|
|
@ -62,5 +62,6 @@ net_dep = declare_dependency(
|
|||
link_with: net,
|
||||
dependencies: [
|
||||
system_dep,
|
||||
io_dep,
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue