diff --git a/Server/src/server.cpp b/Server/src/server.cpp index e0af36b..825ea30 100644 --- a/Server/src/server.cpp +++ b/Server/src/server.cpp @@ -10,9 +10,7 @@ void _TCPClient(Chattr::TCPSocket sock, Chattr::Address addr); int main() { -#ifdef _WIN32 struct Chattr::WSAManager wsaManager; -#endif auto config = Chattr::ConfigManager::load(); Chattr::log::setDefaultLogger(config.logLevel, config.logFileName, config.logfileSize, config.logfileCount); @@ -41,10 +39,11 @@ int main() { sock.accept(clientSock, clientAddr); Chattr::Thread thread_(_TCPClient, std::move(clientSock), clientAddr); + thread_.deatch(); } } void _TCPClient(Chattr::TCPSocket sock, Chattr::Address addr) { spdlog::info("Connection accepted! from: {}, {}", sock, (std::string)addr); - + Sleep(10000); } \ No newline at end of file diff --git a/include/Socket/WSAManager.hpp b/include/Socket/WSAManager.hpp index 86a6eaa..1a8b180 100644 --- a/include/Socket/WSAManager.hpp +++ b/include/Socket/WSAManager.hpp @@ -2,20 +2,23 @@ #include "precomp.hpp" #include "Socket/Log.hpp" -#ifdef _WIN32 + namespace Chattr { struct WSAManager { WSAManager() { +#ifdef _WIN32 WSADATA wsa; if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) log::critical("WSAStartup()"); +#endif } ~WSAManager() { +#ifdef _WIN32 WSACleanup(); +#endif } }; -} -#endif \ No newline at end of file +} \ No newline at end of file