From ed71e8adf36e3d0c3f6f2b54794fe069091d3376 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 6 Jun 2018 20:06:14 +0200 Subject: Add bootstrap class (server) --- include/sibs/DirectConnection.hpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'include/sibs/DirectConnection.hpp') diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp index 8e92137..c4431a5 100644 --- a/include/sibs/DirectConnection.hpp +++ b/include/sibs/DirectConnection.hpp @@ -7,19 +7,12 @@ #include #include #include +#include "IpAddress.hpp" #include "../types.hpp" #include "../utils.hpp" -struct addrinfo; - namespace sibs { - class InvalidAddressException : public std::runtime_error - { - public: - InvalidAddressException(const std::string &errMsg) : std::runtime_error(errMsg) {} - }; - class ConnectionException : public std::runtime_error { public: @@ -32,16 +25,6 @@ namespace sibs SendException(const std::string &errMsg) : std::runtime_error(errMsg) {} }; - class Ipv4 - { - DISABLE_COPY(Ipv4) - public: - // Throws InvalidAddressException on error - Ipv4(const char *ip, u16 port); - ~Ipv4(); - - struct addrinfo *address; - }; enum class PubSubConnectResult { @@ -61,6 +44,7 @@ namespace sibs class DirectConnections { DISABLE_COPY(DirectConnections) + friend class BootstrapNode; public: DirectConnections(u16 port = 27137); ~DirectConnections(); @@ -69,6 +53,8 @@ namespace sibs std::shared_ptr connect(const Ipv4 &address, PubSubReceiveDataCallback receiveDataCallbackFunc); // Throws SendException on error void send(const std::shared_ptr &peer, const void *data, const usize size); + protected: + int createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr); private: void receiveData(); bool receiveDataFromPeer(const int socket, char *output); -- cgit v1.2.3