summaryrefslogtreecommitdiffstats
path: root/vbench/src/vbench/core/socket.h
diff options
context:
space:
mode:
Diffstat (limited to 'vbench/src/vbench/core/socket.h')
-rw-r--r--vbench/src/vbench/core/socket.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/vbench/src/vbench/core/socket.h b/vbench/src/vbench/core/socket.h
new file mode 100644
index 00000000000..4a281555bec
--- /dev/null
+++ b/vbench/src/vbench/core/socket.h
@@ -0,0 +1,34 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "string.h"
+#include "stream.h"
+#include "simple_buffer.h"
+#include <memory>
+
+namespace vbench {
+
+class Socket : public Stream
+{
+private:
+ std::unique_ptr<FastOS_SocketInterface> _socket;
+ SimpleBuffer _input;
+ SimpleBuffer _output;
+ Taint _taint;
+ bool _eof;
+
+public:
+ Socket(std::unique_ptr<FastOS_SocketInterface> socket);
+ Socket(const string host, int port);
+ virtual ~Socket();
+ virtual bool eof() const { return _eof; }
+ virtual Memory obtain(size_t bytes, size_t lowMark);
+ virtual Input &evict(size_t bytes);
+ virtual WritableMemory reserve(size_t bytes);
+ virtual Output &commit(size_t bytes, size_t hiMark);
+ virtual const Taint &tainted() const { return _taint; }
+};
+
+} // namespace vbench
+