-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtcp_sink.h
38 lines (29 loc) · 800 Bytes
/
tcp_sink.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
//
// Author: Alexander Sholohov <[email protected]>
//
// License: MIT
//
#include <vector>
#include "buffer.h"
//---------------------------------------------------------------------------------------
class CTcpSink
{
public:
CTcpSink(int socket, size_t bufferSize, bool backReadEnabled);
void putData(const char* buf, size_t len);
void putData(std::vector<char> data);
void doWrite();
int getSocket() const { return m_socket; }
bool isWritePending() const;
void markForDelete();
bool isNeedDelete() const { return m_needDelete;}
bool isBackReadEnabled() const { return m_backReadEnabled; }
void close();
private:
int m_socket;
CBuffer m_buffer;
bool m_needDelete;
bool m_backReadEnabled;
bool m_errorPrinted;
};