Socket
Librería para comunicar via TCP/IP
 Todo Clases Archivos Funciones Variables 'defines' Páginas
server.h
Ir a la documentación de este archivo.
1 
9 #ifndef SERVER_H_
10 #define SERVER_H_
11 
12 #include "Socket.h"
13 #include "SocketException.h"
14 #include <iostream>
15 #include <sstream>
16 #include <signal.h>
17 #include <fstream>
18 #include <list>
19 #include <fstream>
20 
22 
24 #define N 5
25 
27 #define CONFFILE "socket.conf"
28 
31 using namespace std;
32 
34 
38 class Server
39 {
40  private:
42 
44  int nWorkers;
46 
50 
52  int workerID;
54 
56  list<pthread_t*> stoppedThreads;
58 
63  list<pthread_t*> startedThreads;
65 
69 
70  public:
72 
73  Server() : nWorkers(0), workerID(0), shutdownServer(false) {}
75 
76  int getNWorkers();
78 
79  void setNWorkers(int n );
81 
82  list<pthread_t*>* getStartedThreads();
84 
85  list<pthread_t*>* getStoppedThreads();
87 
88  void startServer(string i , int p);
90 
91  void freeRAM(list<pthread_t*> *threadList);
93 
94  void requestExit();
95 };
96 
98 
103 {
105 
106  pthread_mutex_t *mutex;
108 
112  pthread_cond_t *condition;
114 
116  pthread_t *thread;
118 
122 
126 
127  int id;
128 };
129 
131 
132 void killThread(thread_args *t_arg );
134 
139 void *WorkerThread(void* args );
141 
144 void processText(string *str);
146 
147 bool readConf(string *ip, int *port);
148 
149 #endif /* SERVER_H_ */