-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.h
More file actions
38 lines (35 loc) · 888 Bytes
/
Copy pathServer.h
File metadata and controls
38 lines (35 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <vector>
#include <string>
#include <winsock2.h>
#include <ws2tcpip.h>
#include "Client.h"
//#include <sys/time.h>
#pragma comment(lib, "Ws2_32.lib")
class Server {
public:
Server(int maxClients, const char* port);
~Server();
void run();
void acceptClient();
bool handleClientRequest(Client* client);
void sendToSpecificClient(std::string message, Client* client);
void sendToAllClients(std::string message, Client* sender);
void logMessage(std::string message);
void sendUdpBroadcast();
private:
int maxClients;
std::vector<Client*> clients;
fd_set master;
fd_set read_fds;
SOCKET tcpServerSocket;
SOCKET udpServerSocket;
int fdmax;
const char* port;
std::string logFileName;
int logFile;
void initialize();
timeval timeout;
//Serer information
std::string serverIP;
};