Moving client accept method to socketer

This commit is contained in:
dawidg81 2026-03-08 13:56:43 +01:00
commit 8fec22b413
2 changed files with 19 additions and 8 deletions

View file

@ -2,7 +2,6 @@
sockaddr_in service;
int Socket::winInit()
{
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
@ -50,3 +49,13 @@ int Socket::winListen()
log.info("Network.Socket.winInit: Listening on " + std::string(NET_SOCK_ADDR) + ":" + std::to_string(NET_SOCK_PORT));
return 0;
}
int Socket::winAccept(){
SOCKET clientSocket = accept(socket.mainSocket, NULL, NULL);
if(clientSocket == INVALID_SOCKET){
log.err("Accept failed: " + std::to_string(WSAGetLastError()));
continue;
}
log.info("Client connected");
closesocket(clientSocket);
}

View file

@ -15,8 +15,10 @@ public:
int pInit();
int pBind();
int pListen();
int pAccept();
int winInit();
int winBind();
int winListen();
int winAccept();
};