void TCPNetwork::Run() { //Set select parameters auto readSet = m_readSet; auto writeSet = m_readSet; auto excptSet = m_readSet; timeval timeOut{ 0, 1000 }; //Call select and check result auto selectRet = select(0, &readSet, &writeSet, &excptSet, &timeOut); auto isFDSetChanged = RunCheckSelectResult(selectRet); if (isFDSetChanged == false) { return; } //Process FD elements if (FD_ISSET(m_serverSocket, &readSet)) { NewSession(); } else { RunCheckSelectClient(readSet, writeSet, excptSet); } }
void TcpNetwork::Run() { auto read_set = m_Readfds; auto write_set = m_Readfds; auto exc_set = m_Readfds; timeval timeout{ 0, 1000 }; //tv_sec, tv_usec auto selectResult = select(0, &read_set, &write_set, &exc_set, &timeout); auto isFDSetChanged = RunCheckSelectResult(selectResult); if (isFDSetChanged == false) { return; } // Accept if (FD_ISSET(m_ServerSockfd, &read_set)) { NewSession(); } else // clients { RunCheckSelectClients(exc_set, read_set, write_set); } }