int main()

in CppServerAndClient/Server/Server.cpp [104:149]


int main (int argc, char* argv[]) {
    
    std::cout << "Starting game server, see /logs/myserver1935.log for output" << std::endl;
    
    // Read port from args
    int PORT = 1935; //Default to 1935
    for(int counter=0;counter<argc;counter++)
    {
        if(strcmp(argv[counter], "-port") == 0)
        {
            // Read the next arg which is the port number
            PORT = atoi(argv[counter+1]);
        }
    }
    
    // Forward logs to correct folder for GameLift and CloudWatch Agent to find
    mkdir("./logs", 0777);
    std::string logfile = std::string("logs/myserver");
    logfile += std::to_string(PORT) + ".log";
    freopen(logfile.c_str(),"a",stdout);
    freopen(logfile.c_str(),"a",stderr);
    
    std::cout << "Server port: " << PORT << std::endl;

    // GameLift setup
    std::cout << "Starting server...\n";
	Server *server = new Server();
	server->InitializeGameLift(PORT, logfile);
	
	// NOTE: You should Wait for a game to start before accepting connetions
	
	// Setup the simple blocking TCP Server and accept two players
    int serverResult = SetupTcpServerAndAcceptTwoPlayer(server, PORT);
    
    std::cout << "Then the actual game session would run..." << std::endl;
    
    // Wait a while to simulate a "game session"
    sleep(10);
    
    std::cout << "Game Session done! Clean up session and shutdown" << std::endl;
    
    // Inform GameLift we're shutting down so it can replace the process with a new one
    server->TerminateGameSession();

    return 0;
}