-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMultiplexingServer.h
41 lines (32 loc) · 1.05 KB
/
MultiplexingServer.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
#ifndef MULTIPLEXINGSERVER_H
#define MULTIPLEXINGSERVER_H
#include <map>
#include "SocketBase.h"
#define MAXCLIENTS 10 // how many clients the server can handle
#define BUFFERSIZE 140 // maximum lenghth of the tweets
//The MultiplexingServer class handles everything from accepting clients to I/O multiplexing.
class MultiplexingServer
{
public:
MultiplexingServer();
~MultiplexingServer();
protected:
map<unsigned int, SOCKET> clients;
char* clientMessage;
void configServer(const unsigned short port = 3000);
void clientListener(void);
void sendToClient(const SOCKET* client, const char* message);
void receive(const SOCKET* clientSocket);
virtual void commandInterpreter(char* command[], const SOCKET clientSocket) = 0;
private:
SOCKET requestSocket;
SOCKADDR_IN localhost;
FD_SET actionFlag;
SocketBase socketCreator;
void closeSockets(void);
void acceptClient(void);
void setClientToOffline(SOCKET* clientSocket);
void setClientToOnline(void);
void closeRequestSocket(void) const;
};
#endif // MULTIPLEXINGSERVER_H