1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /*
- * 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;
- bool close();
- 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
- bool _close();
- #ifdef _WIN32
- bool _closeOnWindows() const;
- #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
|