-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.h
More file actions
56 lines (44 loc) · 1.03 KB
/
Server.h
File metadata and controls
56 lines (44 loc) · 1.03 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
#include <array>
#include <iostream>
#include <vector>
#include <string>
#include <pthread.h>
#include "GameBoard.cpp"
#define PORT 2908
#define MAX_NR_OF_PLAYERS 4
struct thData
{
int idThread = -1; // thread id, for each client
int cl; // client descriptor
GameBoard *gameBoard;
int info[7]; // information to send to the clients
int *thread_count; // numbers of threads/clients
int *cl_arr; // array with the clients' descriptors
};
void citeste(void *arg);
static void *treat(void *arg);
class Server
{
private:
struct sockaddr_in server; // server struct
struct sockaddr_in from;
int sd; // socket descriptor
int pid;
pthread_t th[4]; // thread identifiers
GameBoard *gameBoard;
int i;
public:
int cl_arr[4];
int *thread_count;
int initialize();
int acceptLoop();
};