-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTcpServer.h
More file actions
40 lines (29 loc) · 828 Bytes
/
Copy pathTcpServer.h
File metadata and controls
40 lines (29 loc) · 828 Bytes
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
37
38
39
40
#ifndef PILEDSTRIP_SERVER_TCPSERVER_H
#define PILEDSTRIP_SERVER_TCPSERVER_H
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include "Server.h"
class TcpServer;
class TcpConnection
{
public:
explicit TcpConnection(TcpServer* tcpServer, boost::asio::ip::tcp::socket socket);
private:
void startRead();
TcpServer* tcpServer;
boost::asio::ip::tcp::socket socket;
std::vector<unsigned char> buffer;
};
class TcpServer : public Server
{
public:
const uint32_t bufferSize;
explicit TcpServer(boost::asio::io_service& ioService, uint16_t port, uint32_t bufferSize);
void closeConnection(TcpConnection* pConnection);
private:
boost::asio::ip::tcp::acceptor acceptor;
std::list<TcpConnection> connections;
boost::asio::ip::tcp::socket newSocket;
void startAccept();
};
#endif