-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.h
78 lines (61 loc) · 1.68 KB
/
client.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef CLIENTTHREAD_H
#define CLIENTTHREAD_H
#include "common.h"
//POSIX library for threads
#include <pthread.h>
#include <unistd.h>
class Client {
public:
/**
* Identifiant unique du client.
*/
int id;
/**
* Thread identifier
*/
pthread_t pt_tid;
/**
* Resources acquises par le client.
*
* Ceci est de taille numResources.
*/
int* acquired;
static int port;
static int numClients;
static int numResources;
static int numRequests;
Client();
~Client();
/**
* Lance un thread client.
*
* Le thread s'occupe d'effectuer des connections au serveur.
*
* @param param
* @return
*/
static void *run(void* param);
static void printAndSaveResults(const char* fileName);
static int readConfigurationFile(const char *fileName);
static void readMaxFromFile();
/**
* Vérouille la connection et l'écriture sur une stream.
*/
static pthread_mutex_t results_lock;
/**
* Limite le nombre de threads qui peuvent ouvrir le socket.
*/
static sem_t open_limit;
private:
/**
* Nombre maximale de resources que les clients peuvent acquérir.
*/
static int **Max;
// Results variables
static int countAccepted; // Result counter for total acepted requests
static int countOnWait; // Result counter for total request denied and put to wait
static int countInvalid; // Result counter for total invalid requests
static int countClientsDispatched; // Result counter for total clients correctly finished
static int count; // Common counter of created ClienThread to asign an ID
};
#endif // CLIENTTHREAD_H