-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyParallelServer.h
56 lines (44 loc) · 1.26 KB
/
MyParallelServer.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
//
// Created by t on 1/14/19.
//
#ifndef FLIGTSIMPROJ2_MYPARALLELSERVER_H
#define FLIGTSIMPROJ2_MYPARALLELSERVER_H
#include "Server.h"
#include <pthread.h>
#include <vector>
//#include <thread_db.h>
using namespace std;
using namespace server_side;
//struct for the little client talking threads
struct TalkingData {
int newSocket;
ClientHandler *clientHandler;
};
void *clientTalkThreadFunc(void *talkingData);
void* parallelServerThreadFunc(void *serverData);
void stopThreads(vector<pthread_t> *threads, vector<TalkingData*> *talkingStructs);
class MyParallelServer : public Server {
pthread_t threadID;
//vector<pthread_t> threads;
bool setStop = false;
bool doneListening = false;
int socketDescriptor;
struct ServerData *serverData;
int counter = 0;
public:
int listenAccept(int time, struct ServerData *serverData1);
virtual void open(int port, ClientHandler *clientHandler);
virtual void stop();
void setDoneListening(bool done);
bool getDoneListening();
};
//the struct the server thread will get
struct ServerData {
MyParallelServer *parallelServer;
int port;
int socketDescriptor;
ClientHandler *clientHandler;
bool *setStop;
int newSocket;
};
#endif //FLIGTSIMPROJ2_MYPARALLELSERVER_H