DWORD WINAPI AcceptThreadFunc(LPVOID lpThreadParameter) { CServerSocket* Server = (CServerSocket*) lpThreadParameter; while (!Server->IsTerminated()) { // Wait until the socket is listening // TODO: This takes a lot of time! Should be removed to increase performance Server->WaitIsListening(); // Now get handling them new clients Server->AcceptClient(); } return 0; }