void PingThread() { static bool first = true; int iPingTimeout = 0; char szPing[CONFIG_BUFF_SIZE]; while (1) { if (iPingTimeout == CONFIG_PING_TIMEOUT) { srand(GetTickCount()); iPingSeed = rand()%10000; iPingTimeout = 0; sprintf(szPing,"ISALIVE :%i\r\n",iPingSeed); EchoMessage(szPing); if (!first) { for (int i = 0; i < CONFIG_MAX_CLIENTS; i++) { if (!client[i].haspong) DisconnectClient(&client[i]); } } if (!first) first = false; } iPingTimeout++; Sleep(1000); } }