2022-09-20 13:37:06 +00:00
|
|
|
|
/*
|
|
|
|
|
* server.hpp
|
|
|
|
|
*
|
|
|
|
|
* Created on: 20 сент. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
2022-09-20 14:10:09 +00:00
|
|
|
|
#include <connection/connection.hpp>
|
|
|
|
|
#include <vector>
|
2022-09-20 13:37:06 +00:00
|
|
|
|
|
|
|
|
|
namespace azh
|
|
|
|
|
{
|
|
|
|
|
enum class IPV
|
|
|
|
|
{
|
|
|
|
|
V4, V6
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TCPServer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TCPServer(IPV ipv, int port);
|
|
|
|
|
virtual ~TCPServer();
|
|
|
|
|
int run();
|
|
|
|
|
private:
|
|
|
|
|
IPV _ipVersion;
|
|
|
|
|
int _port;
|
|
|
|
|
boost::asio::io_context _ioContext;
|
|
|
|
|
boost::asio::ip::tcp::acceptor _acceptor;
|
2022-09-20 14:10:09 +00:00
|
|
|
|
std::vector<Connection::pointer> _connections;
|
2022-09-20 13:37:06 +00:00
|
|
|
|
private:
|
|
|
|
|
void startAccept();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|