Choose hostname and port (for server and client part)

This commit is contained in:
2025-04-30 15:14:10 +03:00
parent cc1bb79633
commit 3b84aa7740
6 changed files with 88 additions and 45 deletions

View File

@@ -6,16 +6,15 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
const int PORT = 8080;
#include <netdb.h>
class Client{
private:
int sock;
public:
Client() : sock(0){};
void run();
Client();
void run(const std::string& h = "localhost", const unsigned short p = 1024u);
int ping(struct sockaddr_in);
void game();
};
#endif

View File

@@ -7,11 +7,11 @@
#include <thread>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <cstring>
const int PORT = 8080;
const int MAX_CLIENTS = 100;
const int MAX_CLIENTS = 512;
class Server {
private:
@@ -20,7 +20,7 @@ private:
bool check_status(Maze& maze);
public:
Server() : service_mode(false){};
void start(); // Запуск сервера
void start(const std::string& h = "localhost", const unsigned short p = 1024u); // Запуск сервера
};
#endif