diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-31 01:13:15 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | 441cf81acf9dff087addfa8d01a61e4513b1dd6e (patch) | |
tree | 67303309c3cd072c098a1d5dd18c1b0052b62754 /include | |
parent | feafa6421484cbad6947822bcb641fee7ff2ee81 (diff) |
Starting...
Diffstat (limited to 'include')
-rw-r--r-- | include/DirectConnection.hpp | 49 | ||||
-rw-r--r-- | include/types.hpp | 22 | ||||
-rwxr-xr-x | include/utils.hpp | 6 |
3 files changed, 77 insertions, 0 deletions
diff --git a/include/DirectConnection.hpp b/include/DirectConnection.hpp new file mode 100644 index 0000000..c11871f --- /dev/null +++ b/include/DirectConnection.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include <stdexcept> +#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: + ConnectionException(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; + }; + + class DirectConnections + { + DISABLE_COPY(DirectConnections) + public: + DirectConnections(); + ~DirectConnections(); + + void connect(const Ipv4 &address); + private: + void init(); + void cleanup(); + private: + int eid; + int mySocket; + }; +} diff --git a/include/types.hpp b/include/types.hpp new file mode 100644 index 0000000..0379100 --- /dev/null +++ b/include/types.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include <cstdint> + +namespace sibs +{ + typedef int8_t i8; + typedef int16_t i16; + typedef int32_t i32; + typedef int64_t i64; + + typedef uint8_t u8; + typedef uint16_t u16; + typedef uint32_t u32; + typedef uint64_t u64; + + typedef float f32; + typedef double f64; + + typedef intptr_t isize; + typedef uintptr_t usize; +} diff --git a/include/utils.hpp b/include/utils.hpp new file mode 100755 index 0000000..01e478d --- /dev/null +++ b/include/utils.hpp @@ -0,0 +1,6 @@ +#pragma once + +// Disable copying for a class or struct +#define DISABLE_COPY(ClassName) \ + ClassName(ClassName&) = delete; \ + ClassName& operator = (ClassName&) = delete; |