wsa미세조정 및 스레드 테스트용 딜레이 코드 추가

This commit is contained in:
2025-04-26 17:31:45 +09:00
parent 1418cf6880
commit df95bde226
2 changed files with 8 additions and 6 deletions

View File

@@ -10,9 +10,7 @@
void _TCPClient(Chattr::TCPSocket sock, Chattr::Address addr); void _TCPClient(Chattr::TCPSocket sock, Chattr::Address addr);
int main() { int main() {
#ifdef _WIN32
struct Chattr::WSAManager wsaManager; struct Chattr::WSAManager wsaManager;
#endif
auto config = Chattr::ConfigManager::load(); auto config = Chattr::ConfigManager::load();
Chattr::log::setDefaultLogger(config.logLevel, config.logFileName, config.logfileSize, config.logfileCount); Chattr::log::setDefaultLogger(config.logLevel, config.logFileName, config.logfileSize, config.logfileCount);
@@ -41,10 +39,11 @@ int main() {
sock.accept(clientSock, clientAddr); sock.accept(clientSock, clientAddr);
Chattr::Thread thread_(_TCPClient, std::move(clientSock), clientAddr); Chattr::Thread thread_(_TCPClient, std::move(clientSock), clientAddr);
thread_.deatch();
} }
} }
void _TCPClient(Chattr::TCPSocket sock, Chattr::Address addr) { void _TCPClient(Chattr::TCPSocket sock, Chattr::Address addr) {
spdlog::info("Connection accepted! from: {}, {}", sock, (std::string)addr); spdlog::info("Connection accepted! from: {}, {}", sock, (std::string)addr);
Sleep(10000);
} }

View File

@@ -2,20 +2,23 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "Socket/Log.hpp" #include "Socket/Log.hpp"
#ifdef _WIN32
namespace Chattr { namespace Chattr {
struct WSAManager { struct WSAManager {
WSAManager() { WSAManager() {
#ifdef _WIN32
WSADATA wsa; WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
log::critical("WSAStartup()"); log::critical("WSAStartup()");
#endif
} }
~WSAManager() { ~WSAManager() {
#ifdef _WIN32
WSACleanup(); WSACleanup();
#endif
} }
}; };
} }
#endif