geekbrains_network_programming/lesson_04/server/tcp_server.hpp

38 lines
630 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* server.hpp
*
* Created on: 20 сент. 2022 г.
* Author: alexander
*/
#pragma once
#include <boost/asio.hpp>
#include <connection/connection.hpp>
#include <vector>
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;
std::vector<Connection::pointer> _connections;
private:
void startAccept();
};
}