Socket.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2022-11-16
  6. * Changed: 2022-12-09
  7. *
  8. * */
  9. #ifndef LS_STD_SOCKET_HPP
  10. #define LS_STD_SOCKET_HPP
  11. #include <ls_std/os/dynamic_goal.hpp>
  12. #include <ls_std/core/Class.hpp>
  13. #include "SocketParameter.hpp"
  14. #include "SocketAddressMapperParameter.hpp"
  15. namespace ls::std::network
  16. {
  17. class LS_STD_DYNAMIC_GOAL Socket : public ls::std::core::Class
  18. {
  19. public:
  20. explicit Socket(const ls::std::network::SocketParameter& _parameter);
  21. ~Socket() override = default;
  22. [[nodiscard]] bool connect();
  23. [[nodiscard]] bool isInitialized() const;
  24. private:
  25. bool initialized{};
  26. ls::std::network::SocketParameter parameter{};
  27. #if defined(unix) || defined(__APPLE__)
  28. int unixDescriptor{};
  29. #endif
  30. #if defined(unix) || defined(__APPLE__)
  31. [[nodiscard]] bool _connectUnix() const;
  32. #endif
  33. [[nodiscard]] SocketAddressMapperParameter _createSocketAddressMapperParameter() const;
  34. [[nodiscard]] static bool _init(const ls::std::network::SocketParameter& _parameter);
  35. #if defined(unix) || defined(__APPLE__)
  36. [[nodiscard]] static bool _initUnix(const ls::std::network::SocketParameter& _parameter);
  37. #endif
  38. };
  39. }
  40. #endif