Socket.hpp 1.2 KB

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