12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /*
- * Author: Patrick-Christopher Mattulat
- * Company: Lynar Studios
- * E-Mail: webmaster@lynarstudios.com
- * Created: 2020-12-06
- * Changed: 2020-12-06
- *
- * */
- #ifndef LS_STD_SOCKET_HPP
- #define LS_STD_SOCKET_HPP
- #include <ls_std/base/Class.hpp>
- #include "AddressFamily.hpp"
- #include "SocketType.hpp"
- #include "NetworkProtocol.hpp"
- #if defined(unix) || defined(__APPLE__)
- #include <sys/types.h>
- #include <sys/socket.h>
- #endif
- #ifdef _WIN32
- #include <winsock2.h>
- #endif
- namespace ls_std {
- class Socket : public ls_std::Class {
- public:
- Socket();
- ~Socket() override = default;
- bool create(ls_std::AddressFamily _addressFamily, ls_std::SocketType _socketType, ls_std::NetworkProtocol _networkProtocol);
- private:
- #if defined(unix) || defined(__APPLE__)
- int descriptor {};
- #endif
- #ifdef _WIN32
- SOCKET descriptor {};
- #endif
- static int _convertAddressFamily(ls_std::AddressFamily _addressFamily);
- static int _convertNetworkProtocol(ls_std::NetworkProtocol _networkProtocol);
- static int _convertSocketType(ls_std::SocketType _socketType);
- #if defined(unix) || defined(__APPLE__)
- static int _create(ls_std::AddressFamily _addressFamily, ls_std::SocketType _socketType, ls_std::NetworkProtocol _networkProtocol);
- #endif
- #ifdef _WIN32
- static SOCKET _create(ls_std::AddressFamily _addressFamily, ls_std::SocketType _socketType, ls_std::NetworkProtocol _networkProtocol);
- #endif
- };
- }
- #endif
|