aboutsummaryrefslogtreecommitdiff
path: root/include/sibs/BootstrapNode.hpp
blob: eaf48eb5e2b5e337a974ec365b58b10ffca361a8 (plain)
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
#pragma once

#include "DirectConnection.hpp"
#include "IpAddress.hpp"

namespace sibs
{
    class BootstrapException : public std::runtime_error
    {
    public:
        BootstrapException(const std::string &errMsg) : std::runtime_error(errMsg) {}
    };
    
    class BootstrapNode
    {
        DISABLE_COPY(BootstrapNode)
    public:
        // Throws BootstrapException on error
        BootstrapNode(const Ipv4 &address);
        ~BootstrapNode();
    private:
        void acceptConnections();
    private:
        DirectConnections connections;
        int socket;
        std::thread acceptConnectionsThread;
    };
}