danicoin/src/System/TcpStream.h

34 lines
837 B
C
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-09-15 10:48:45 +00:00
#pragma once
#include <array>
2015-05-27 12:08:46 +00:00
#include <cstdint>
#include <streambuf>
namespace System {
2014-09-15 10:48:45 +00:00
2015-05-27 12:08:46 +00:00
class TcpConnection;
2014-09-15 10:48:45 +00:00
class TcpStreambuf : public std::streambuf {
public:
2015-05-27 12:08:46 +00:00
explicit TcpStreambuf(TcpConnection& connection);
2014-09-15 10:48:45 +00:00
TcpStreambuf(const TcpStreambuf&) = delete;
2015-05-27 12:08:46 +00:00
~TcpStreambuf();
TcpStreambuf& operator=(const TcpStreambuf&) = delete;
2014-09-15 10:48:45 +00:00
private:
TcpConnection& connection;
std::array<char, 4096> readBuf;
2015-05-27 12:08:46 +00:00
std::array<uint8_t, 1024> writeBuf;
std::streambuf::int_type overflow(std::streambuf::int_type ch) override;
int sync() override;
std::streambuf::int_type underflow() override;
bool dumpBuffer(bool finalize);
2014-09-15 10:48:45 +00:00
};
}