summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-08-21 11:31:58 +0200
committerMax Kellermann <max@musicpd.org>2018-08-21 11:31:58 +0200
commitfd923d5d96e33d5a677139a9fdfe5e8349b07638 (patch)
tree852a0cd9648f887a8a748b6ef16aeac63a3061f1 /src
parentebf607eef8b1592a2c9eb05d82934c5b5d4dc337 (diff)
net/SocketDescriptor: add Shutdown()
Diffstat (limited to 'src')
-rw-r--r--src/net/SocketDescriptor.cxx22
-rw-r--r--src/net/SocketDescriptor.hxx6
2 files changed, 28 insertions, 0 deletions
diff --git a/src/net/SocketDescriptor.cxx b/src/net/SocketDescriptor.cxx
index 46c6a2240..8d7779ca0 100644
--- a/src/net/SocketDescriptor.cxx
+++ b/src/net/SocketDescriptor.cxx
@@ -488,3 +488,25 @@ SocketDescriptor::Write(const void *buffer, size_t length,
return ::sendto(Get(), (const char *)buffer, length, flags,
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
diff --git a/src/net/SocketDescriptor.hxx b/src/net/SocketDescriptor.hxx
index 89eb2abd9..212e10c7c 100644
--- a/src/net/SocketDescriptor.hxx
+++ b/src/net/SocketDescriptor.hxx
@@ -241,6 +241,12 @@ public:
*/
ssize_t Write(const void *buffer, size_t length,
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");