-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
62 lines (52 loc) · 1.57 KB
/
main.cpp
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
#include <iostream>
using namespace std;
#include "bankServer.h"
#include "bankAccount.h"
#include "transaction.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h> /* sockets */
#include <netinet/in.h> /* internet sockets */
#include <netdb.h> /* gethostbyaddr */
#include "readWriteFunct.h"
#define HASHTABLESIZE 100000
int main(int argc, char *argv[])
{
int workThreads = -1 , queueSize = -1, port = -1, hashTSize = HASHTABLESIZE;
if (argc != 7)
{
cout<<"Please give all attributes -p <port> -s <thread pool size> -q <queue size>"<<endl;
exit(1);
}
for(int i=1; i < argc; i++) //diavasma parametrwn apo grammi entolis me morfi -p <port> -s <thread pool size> -q <queue size>
{
if(i+1 != argc)
{
if(strcmp(argv[i], "-p") == 0)
{
port = atoi(argv[i+1]);
}
else if(strcmp(argv[i], "-s") == 0)
{
workThreads = atoi(argv[i+1]);
}
else if(strcmp(argv[i], "-q") == 0)
{
queueSize = atoi(argv[i+1]);
}
}
}
if(port == -1 || workThreads == -1 || queueSize == -1)
{
cout<<"Please give all attributes -p <port> -s <thread pool size> -q <queue size>"<<endl;
exit(1);
}
BankServer* server = new BankServer(hashTSize, queueSize);
server->masterThread(port, workThreads); //trexw ton server
delete server;
}