#pragma once #include #include #include #if defined(OS_WINDOWS) #include #include #include #define SOCKET_NONE INVALID_SOCKET #else #include #include #include #include #include #define SOCKET_NONE -1 #endif namespace hex { class Socket { public: Socket() = default; Socket(const Socket &) = delete; Socket(Socket &&other) noexcept; Socket(const std::string &address, u16 port); ~Socket(); void connect(const std::string &address, u16 port); void disconnect(); [[nodiscard]] bool isConnected() const; [[nodiscard]] std::string readString(size_t size = 0x1000) const; [[nodiscard]] std::vector readBytes(size_t size = 0x1000) const; void writeString(const std::string &string) const; void writeBytes(const std::vector &bytes) const; private: bool m_connected = false; #if defined(OS_WINDOWS) SOCKET m_socket = SOCKET_NONE; #else int m_socket = SOCKET_NONE; #endif }; }