net/SocketDescriptor: add Shutdown()
This commit is contained in:
@@ -488,3 +488,25 @@ SocketDescriptor::Write(const void *buffer, size_t length,
|
|||||||
return ::sendto(Get(), (const char *)buffer, length, flags,
|
return ::sendto(Get(), (const char *)buffer, length, flags,
|
||||||
address.GetAddress(), address.GetSize());
|
address.GetAddress(), address.GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
|
||||||
|
void
|
||||||
|
SocketDescriptor::Shutdown() noexcept
|
||||||
|
{
|
||||||
|
shutdown(Get(), SHUT_RDWR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SocketDescriptor::ShutdownRead() noexcept
|
||||||
|
{
|
||||||
|
shutdown(Get(), SHUT_RD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SocketDescriptor::ShutdownWrite() noexcept
|
||||||
|
{
|
||||||
|
shutdown(Get(), SHUT_WR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -241,6 +241,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
ssize_t Write(const void *buffer, size_t length,
|
ssize_t Write(const void *buffer, size_t length,
|
||||||
SocketAddress address) noexcept;
|
SocketAddress address) noexcept;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
void Shutdown() noexcept;
|
||||||
|
void ShutdownRead() noexcept;
|
||||||
|
void ShutdownWrite() noexcept;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(std::is_trivial<SocketDescriptor>::value, "type is not trivial");
|
static_assert(std::is_trivial<SocketDescriptor>::value, "type is not trivial");
|
||||||
|
Reference in New Issue
Block a user