Explorar o código

Introduce global unix build macro for Socket class

Patrick-Christopher Mattulat %!s(int64=2) %!d(string=hai) anos
pai
achega
517e389ca5

+ 16 - 0
include/ls_std/ls_std_os.hpp

@@ -0,0 +1,16 @@
+/*
+ * Author:          Patrick-Christopher Mattulat
+ * Company:         Lynar Studios
+ * E-Mail:          webmaster@lynarstudios.com
+ * Created:         2020-12-26
+ * Changed:         2022-12-26
+ *
+ * */
+
+#ifndef LS_STD_LS_STD_OS_HPP
+#define LS_STD_LS_STD_OS_HPP
+
+#include <ls_std/os/dynamic_goal.hpp>
+#include <ls_std/os/specification.hpp>
+
+#endif

+ 3 - 2
include/ls_std/network/core/ProtocolFamilyMapper.hpp

@@ -3,13 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-16
- * Changed:         2022-12-09
+ * Changed:         2022-12-26
  *
  * */
 
 #ifndef LS_STD_PROTOCOL_FAMILY_MAPPER_HPP
 #define LS_STD_PROTOCOL_FAMILY_MAPPER_HPP
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/core/Class.hpp>
 #include <ls_std/network/core/ConvertedProtocolFamily.hpp>
 #include <ls_std/network/core/ProtocolFamilyType.hpp>
@@ -28,7 +29,7 @@ namespace ls::std::network
 
     private:
 
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       [[nodiscard]] static ls::std::network::ConvertedProtocolFamily _toUnixProtocolFamily(const ls::std::network::ProtocolFamilyType& _protocolFamilyType);
       #endif
   };

+ 3 - 2
include/ls_std/network/core/ProtocolMapper.hpp

@@ -3,13 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-17
- * Changed:         2022-11-17
+ * Changed:         2022-12-26
  *
  * */
 
 #ifndef LS_STD_PROTOCOL_MAPPER_HPP
 #define LS_STD_PROTOCOL_MAPPER_HPP
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/os/dynamic_goal.hpp>
 #include <ls_std/core/Class.hpp>
 #include "Protocol.hpp"
@@ -28,7 +29,7 @@ namespace ls::std::network
 
     private:
 
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       [[nodiscard]] static ls::std::network::Protocol _toUnixProtocol(const ls::std::network::ProtocolType& _protocolType);
       #endif
   };

+ 5 - 3
include/ls_std/network/socket/ConvertedSocketAddress.hpp

@@ -3,14 +3,16 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-18
- * Changed:         2022-12-12
+ * Changed:         2022-12-26
  *
  * */
 
 #ifndef LS_STD_CONVERTED_SOCKET_ADDRESS_HPP
 #define LS_STD_CONVERTED_SOCKET_ADDRESS_HPP
 
-#if defined(unix) || defined(__APPLE__)
+#include <ls_std/os/specification.hpp>
+
+#if LS_STD_UNIX_PLATFORM
 #include <netinet/in.h>
 #endif
 
@@ -18,7 +20,7 @@ namespace ls::std::network
 {
   struct ConvertedSocketAddress
   {
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     ::sockaddr_in socketAddressUnix{};
     ::socklen_t addressLength{};
     #endif

+ 6 - 5
include/ls_std/network/socket/Socket.hpp

@@ -10,6 +10,7 @@
 #ifndef LS_STD_SOCKET_HPP
 #define LS_STD_SOCKET_HPP
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/os/dynamic_goal.hpp>
 #include <ls_std/core/Class.hpp>
 #include "SocketParameter.hpp"
@@ -48,11 +49,11 @@ namespace ls::std::network
       ls::std::network::SocketParameter parameter{};
       ls::std::core::type::byte* readBuffer{};
       bool readBufferSet{};
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       int unixDescriptor{};
       #endif
 
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       [[nodiscard]] bool _acceptUnix();
       [[nodiscard]] bool _bindUnix();
       [[nodiscard]] bool _closeUnix();
@@ -61,19 +62,19 @@ namespace ls::std::network
       [[nodiscard]] SocketAddressMapperParameter _createSocketAddressMapperParameter() const;
       void _init();
       void _initReadBuffer();
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       [[nodiscard]] bool _initUnix();
       [[nodiscard]] bool _listenUnix();
       #endif
       ls::std::core::type::byte_field _read();
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       ls::std::core::type::byte_field _readUnix();
       void _setPosixReaderApi();
       void _setPosixSocketApi();
       void _setPosixWriterApi();
       #endif
       bool _write(const ls::std::core::type::byte_field &_data);
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       bool _writeUnix(const ls::std::core::type::byte_field &_data);
       #endif
   };

+ 4 - 3
include/ls_std/network/socket/SocketAddressMapper.hpp

@@ -3,18 +3,19 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-18
- * Changed:         2022-11-18
+ * Changed:         2022-12-26
  *
  * */
 
 #ifndef LS_STD_SOCKET_ADDRESS_MAPPER_HPP
 #define LS_STD_SOCKET_ADDRESS_MAPPER_HPP
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/core/Class.hpp>
 #include <ls_std/os/dynamic_goal.hpp>
 #include "ConvertedSocketAddress.hpp"
 #include "SocketAddressMapperParameter.hpp"
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <netinet/in.h>
 #endif
 
@@ -31,7 +32,7 @@ namespace ls::std::network
 
     private:
 
-      #if defined(unix) || defined(__APPLE__)
+      #if LS_STD_UNIX_PLATFORM
       [[nodiscard]] static ::sockaddr_in _toSockAddressUnix(const ls::std::network::SocketAddressMapperParameter& _parameter);
       #endif
   };

+ 25 - 0
include/ls_std/os/specification.hpp

@@ -0,0 +1,25 @@
+/*
+ * Author:          Patrick-Christopher Mattulat
+ * Company:         Lynar Studios
+ * E-Mail:          webmaster@lynarstudios.com
+ * Created:         2022-12-26
+ * Changed:         2022-12-26
+ *
+ * */
+
+#ifndef LS_STD_SPECIFICATION_HPP
+#define LS_STD_SPECIFICATION_HPP
+
+#if defined(unix) || defined(__APPLE__)
+#define LS_STD_UNIX_PLATFORM (1==1)
+#else
+#define LS_STD_UNIX_PLATFORM (1==0)
+#endif
+
+#ifdef _WIN32
+#define LS_STD_WINDOWS_PLATFORM (1==1)
+#else
+#define LS_STD_WINDOWS_PLATFORM (1==0)
+#endif
+
+#endif

+ 5 - 4
source/ls_std/network/core/ProtocolFamilyMapper.cpp

@@ -3,13 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-16
- * Changed:         2022-12-09
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/network/core/ProtocolFamilyMapper.hpp>
 #include <ls_std/core/exception/IllegalArgumentException.hpp>
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <sys/socket.h>
 #endif
 
@@ -18,12 +19,12 @@ ls::std::network::ProtocolFamilyMapper::ProtocolFamilyMapper() : ls::std::core::
 
 ls::std::network::ConvertedProtocolFamily ls::std::network::ProtocolFamilyMapper::from(const ls::std::network::ProtocolFamilyType &_protocolFamilyType)
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::ProtocolFamilyMapper::_toUnixProtocolFamily(_protocolFamilyType);
   #endif
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 ls::std::network::ConvertedProtocolFamily ls::std::network::ProtocolFamilyMapper::_toUnixProtocolFamily(const ls::std::network::ProtocolFamilyType &_protocolFamilyType)
 {
   ls::std::network::ConvertedProtocolFamily convertedProtocolFamily{};

+ 5 - 4
source/ls_std/network/core/ProtocolMapper.cpp

@@ -3,12 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-17
- * Changed:         2022-12-12
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/network/core/ProtocolMapper.hpp>
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <sys/socket.h>
 #endif
 #include <ls_std/core/exception/IllegalArgumentException.hpp>
@@ -18,12 +19,12 @@ ls::std::network::ProtocolMapper::ProtocolMapper() : ls::std::core::Class("Proto
 
 ls::std::network::Protocol ls::std::network::ProtocolMapper::from(const ls::std::network::ProtocolType &_protocolType)
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::ProtocolMapper::_toUnixProtocol(_protocolType);
   #endif
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 ls::std::network::Protocol ls::std::network::ProtocolMapper::_toUnixProtocol(const ls::std::network::ProtocolType &_protocolType)
 {
   ls::std::network::Protocol protocol{};

+ 13 - 12
source/ls_std/network/socket/Socket.cpp

@@ -7,6 +7,7 @@
  *
  * */
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/network/socket/Socket.hpp>
 #include <ls_std/network/core/ProtocolFamilyMapper.hpp>
 #include <ls_std/network/core/ProtocolMapper.hpp>
@@ -54,28 +55,28 @@ bool ls::std::network::Socket::accept()
     throw ls::std::core::WrongProtocolException{};
   }
 
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::Socket::_acceptUnix();
   #endif
 }
 
 bool ls::std::network::Socket::bind()
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::Socket::_bindUnix();
   #endif
 }
 
 bool ls::std::network::Socket::close()
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::Socket::_closeUnix();
   #endif
 }
 
 bool ls::std::network::Socket::connect()
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::Socket::_connectUnix();
   #endif
 }
@@ -92,12 +93,12 @@ bool ls::std::network::Socket::listen()
     throw ls::std::core::WrongProtocolException{};
   }
 
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return ls::std::network::Socket::_listenUnix();
   #endif
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 
 bool ls::std::network::Socket::_acceptUnix()
 {
@@ -134,7 +135,7 @@ ls::std::network::SocketAddressMapperParameter ls::std::network::Socket::_create
 
 void ls::std::network::Socket::_init()
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   this->unixDescriptor = ls::std::network::Socket::_initUnix();
   this->initialized = this->unixDescriptor != -1;
   #endif
@@ -150,7 +151,7 @@ void ls::std::network::Socket::_initReadBuffer()
   this->readBuffer = new ls::std::core::type::byte[this->parameter.readBufferSize];
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 bool ls::std::network::Socket::_initUnix()
 {
   this->_setPosixReaderApi();
@@ -170,12 +171,12 @@ bool ls::std::network::Socket::_listenUnix()
 
 ls::std::core::type::byte_field ls::std::network::Socket::_read()
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return this->_readUnix();
   #endif
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 ls::std::core::type::byte_field ls::std::network::Socket::_readUnix()
 {
   size_t size = this->parameter.posixReader->read(this->unixDescriptor, this->readBuffer, this->parameter.readBufferSize);
@@ -215,12 +216,12 @@ void ls::std::network::Socket::_setPosixWriterApi()
 
 bool ls::std::network::Socket::_write(const ls::std::core::type::byte_field &_data)
 {
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   return this->_writeUnix(_data);
   #endif
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 bool ls::std::network::Socket::_writeUnix(const ls::std::core::type::byte_field &_data)
 {
   bool written{};

+ 5 - 4
source/ls_std/network/socket/SocketAddressMapper.cpp

@@ -3,14 +3,15 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-18
- * Changed:         2022-12-12
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/os/specification.hpp>
 #include <ls_std/network/socket/SocketAddressMapper.hpp>
 #include <ls_std/network/core/ConvertedProtocolFamily.hpp>
 #include <ls_std/network/core/ProtocolFamilyMapper.hpp>
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #endif
@@ -22,7 +23,7 @@ ls::std::network::ConvertedSocketAddress ls::std::network::SocketAddressMapper::
 {
   ls::std::network::ConvertedSocketAddress convertedSocketAddress{};
 
-  #if defined(unix) || defined(__APPLE__)
+  #if LS_STD_UNIX_PLATFORM
   convertedSocketAddress.socketAddressUnix = ls::std::network::SocketAddressMapper::_toSockAddressUnix(_parameter);
   convertedSocketAddress.addressLength = sizeof(convertedSocketAddress.socketAddressUnix);
   #endif
@@ -30,7 +31,7 @@ ls::std::network::ConvertedSocketAddress ls::std::network::SocketAddressMapper::
   return convertedSocketAddress;
 }
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 ::sockaddr_in ls::std::network::SocketAddressMapper::_toSockAddressUnix(const ls::std::network::SocketAddressMapperParameter &_parameter)
 {
   ::sockaddr_in socketAddressUnix{};

+ 4 - 3
test/cases/network/core/ProtocolFamilyMapperTest.cpp

@@ -3,13 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-16
- * Changed:         2022-12-09
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/ls_std_os.hpp>
 #include <gtest/gtest.h>
 #include <ls_std/ls_std_network.hpp>
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <sys/socket.h>
 #endif
 #include <ls_std/ls_std_core.hpp>
@@ -42,7 +43,7 @@ namespace
   {
     ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4);
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     ASSERT_EQ(AF_INET, convertedProtocolFamily.unixDomain);
     #endif
   }

+ 4 - 3
test/cases/network/core/ProtocolMapperTest.cpp

@@ -3,13 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-17
- * Changed:         2022-11-17
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/ls_std_os.hpp>
 #include <gtest/gtest.h>
 #include <ls_std/ls_std_network.hpp>
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <sys/socket.h>
 #endif
 #include <ls_std/ls_std_core.hpp>
@@ -42,7 +43,7 @@ namespace
   {
     Protocol protocol = ProtocolMapper::from(ProtocolType::PROTOCOL_TYPE_TCP);
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     ASSERT_EQ(SOCK_STREAM, protocol.unixProtocol);
     #endif
   }

+ 4 - 3
test/cases/network/socket/SocketAddressMapperTest.cpp

@@ -3,14 +3,15 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-18
- * Changed:         2022-12-12
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/ls_std_os.hpp>
 #include <gtest/gtest.h>
 #include <ls_std/ls_std_network.hpp>
 
-#if defined(unix) || defined(__APPLE__)
+#if LS_STD_UNIX_PLATFORM
 #include <sys/socket.h>
 #endif
 
@@ -55,7 +56,7 @@ namespace
   {
     ConvertedSocketAddress convertedSocketAddress = SocketAddressMapper::from(createSocketAddressMapperParameter());
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     ASSERT_EQ(36895, convertedSocketAddress.socketAddressUnix.sin_port); // expected: return value of htons()
     ASSERT_EQ(AF_INET, convertedSocketAddress.socketAddressUnix.sin_family);
     ASSERT_EQ(16777343, convertedSocketAddress.socketAddressUnix.sin_addr.s_addr); // expected: return value of inet_aton()

+ 13 - 12
test/cases/network/socket/SocketTest.cpp

@@ -3,10 +3,11 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-16
- * Changed:         2022-12-25
+ * Changed:         2022-12-26
  *
  * */
 
+#include <ls_std/ls_std_os.hpp>
 #include <gtest/gtest.h>
 #include <ls_std/ls_std_network.hpp>
 #include <ls_std/ls_std_core.hpp>
@@ -60,7 +61,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     shared_ptr<MockPosixReader> mockReader = make_shared<MockPosixReader>();
     parameter.posixSocket = mockSocket;
@@ -82,7 +83,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -108,7 +109,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     shared_ptr<MockPosixReader> mockReader = make_shared<MockPosixReader>();
     parameter.posixSocket = mockSocket;
@@ -139,7 +140,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     shared_ptr<MockPosixWriter> mockWriter = make_shared<MockPosixWriter>();
     parameter.posixSocket = mockSocket;
@@ -160,7 +161,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -179,7 +180,7 @@ namespace
     SocketParameter parameter = generateSocketParameter();
     parameter.socketAddress.protocolType = PROTOCOL_TYPE_UDP;
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -205,7 +206,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -223,7 +224,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -241,7 +242,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -265,7 +266,7 @@ namespace
   {
     SocketParameter parameter = generateSocketParameter();
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;
 
@@ -284,7 +285,7 @@ namespace
     SocketParameter parameter = generateSocketParameter();
     parameter.socketAddress.protocolType = PROTOCOL_TYPE_UDP;
 
-    #if defined(unix) || defined(__APPLE__)
+    #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
     parameter.posixSocket = mockSocket;