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/IpAddress.hpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/sibs/IpAddress.hpp (limited to 'include/sibs/IpAddress.hpp') diff --git a/include/sibs/IpAddress.hpp b/include/sibs/IpAddress.hpp new file mode 100644 index 0000000..a0fad75 --- /dev/null +++ b/include/sibs/IpAddress.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "../utils.hpp" +#include +#include +#ifndef WIN32 + #include + #include +#else + #include + #include +#endif + +namespace sibs +{ + class InvalidAddressException : public std::runtime_error + { + public: + InvalidAddressException(const std::string &errMsg) : std::runtime_error(errMsg) {} + }; + + class Ipv4 + { + DISABLE_COPY(Ipv4) + public: + // If @ip is nullptr, then bind to all available sockets (typical for servers) + // Throws InvalidAddressException on error. + Ipv4(const char *ip, unsigned short port); + + std::string getAddress() const; + unsigned short getPort() const; + + struct sockaddr_in address; + }; +} -- cgit v1.2.3