aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/BufferedSocket.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-30 10:39:17 +0100
committerMax Kellermann <max@duempel.org>2013-01-30 10:39:17 +0100
commit73f36858bb4026eff7c9e44007c87e870d324a5f (patch)
treebd42fc660f2a29e8553563dc03bccd51a7e54e5f /src/event/BufferedSocket.cxx
parentfe3f0332f71258354b70e5db685b56934f0df703 (diff)
downloadmpd-73f36858bb4026eff7c9e44007c87e870d324a5f.tar.gz
mpd-73f36858bb4026eff7c9e44007c87e870d324a5f.tar.xz
mpd-73f36858bb4026eff7c9e44007c87e870d324a5f.zip
event/SocketMonitor: add methods Read(), Write()
Diffstat (limited to '')
-rw-r--r--src/event/BufferedSocket.cxx24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/event/BufferedSocket.cxx b/src/event/BufferedSocket.cxx
index f84fe808b..b95519e49 100644
--- a/src/event/BufferedSocket.cxx
+++ b/src/event/BufferedSocket.cxx
@@ -26,11 +26,6 @@
#include <stdint.h>
#include <string.h>
-#ifndef WIN32
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
BufferedSocket::~BufferedSocket()
{
if (input != nullptr)
@@ -40,15 +35,7 @@ BufferedSocket::~BufferedSocket()
BufferedSocket::ssize_t
BufferedSocket::DirectWrite(const void *data, size_t length)
{
- int flags = 0;
-#ifdef MSG_NOSIGNAL
- flags |= MSG_NOSIGNAL;
-#endif
-#ifdef MSG_DONTWAIT
- flags |= MSG_DONTWAIT;
-#endif
-
- const auto nbytes = send(Get(), (const char *)data, length, flags);
+ const auto nbytes = SocketMonitor::Write((const char *)data, length);
if (gcc_unlikely(nbytes < 0)) {
const auto code = GetSocketError();
if (IsSocketErrorAgain(code))
@@ -65,15 +52,10 @@ BufferedSocket::DirectWrite(const void *data, size_t length)
return nbytes;
}
-ssize_t
+BufferedSocket::ssize_t
BufferedSocket::DirectRead(void *data, size_t length)
{
- int flags = 0;
-#ifdef MSG_DONTWAIT
- flags |= MSG_DONTWAIT;
-#endif
-
- const auto nbytes = recv(Get(), (char *)data, length, flags);
+ const auto nbytes = SocketMonitor::Read((char *)data, length);
if (gcc_likely(nbytes > 0))
return nbytes;