#include "server.h" #include #include #include #include #include #include #include #include #include #include "net.h" #include "filesystem.h" void RunServerForGame(CTTRTSGame &game) { std::cout<<"Setting up server on port "< players = game.GetPlayers(); unsigned int numClients = players.size(); auto player_iterator = players.begin(); // game mutex std::mutex gameMutex; // Set of clients std::vector myClients; std::cout<<"Waiting for clients"<< std::endl; // Loop while we're connecting the clients while ( myClients.size() < numClients ) { // information for each client sockaddr_in cli_addr; // Client address int clientsockfd; // new socket File descriptor socklen_t clilen = sizeof(sockaddr_in); // accept waits for a connection from a client // it returns a new socket file descriptor for this connection // client information will be stored in cli_addr clientsockfd = accept(sockfd, (sockaddr *) &cli_addr, &clilen); if (clientsockfd < 0) fatal_perror("ERROR on accept"); std::cout<<"Client connected from "<