1 #ifndef GCP_UTIL_SERVER_H
2 #define GCP_UTIL_SERVER_H
15 #include "gcp/util/common/FdSet.h"
16 #include "gcp/util/common/NetDat.h"
17 #include "gcp/util/common/NetHandler.h"
18 #include "gcp/util/common/Runnable.h"
19 #include "gcp/util/common/SignalTaskMsg.h"
20 #include "gcp/util/common/TimeOut.h"
38 unsigned readBufSize,
unsigned sendBufSize,
47 Server(
bool spawnThread,
int listenPort,
unsigned readBufSize=0,
48 unsigned sendBufSize=0);
62 unsigned readBufSize_;
64 unsigned sendBufSize_;
70 virtual void timeOutAction() {};
74 virtual void readClientData(
NetHandler& handler) {};
78 virtual void acceptClientAction() {};
82 virtual void checkOtherFds() {};
86 void setReadBufSize(
unsigned size);
87 void setSendBufSize(
unsigned size);
89 void setTimeOutSeconds(
unsigned int seconds);
100 unsigned int timeOutSeconds_;
120 std::list<ServerConnection*> clients_;
125 void initMembers(
int listenPort,
unsigned readBufSize,
unsigned sendBufSize);
131 void listen(
unsigned port,
unsigned nClients = 5);
136 void sendShutdownMsg();
141 void acceptConnection();
158 static SIGNALTASK_HANDLER_FN(shutDown);
163 static RUN_FN(runFn);
167 void checkClientsForReadableData();
171 void checkClientsForWritability();
173 static NET_READ_HANDLER(readHandler);
174 static NET_SEND_HANDLER(sendHandler);
175 static NET_ERROR_HANDLER(errHandler);
184 #endif // End #ifndef GCP_UTIL_SERVER_H
ServerConnection(int fd, unsigned readBufSize, unsigned sendBufSize, Server *parent)
Definition: Server.cc:307
FdSet fdSet_
Definition: Server.h:96
Definition: SignalTask.h:53
Definition: NetHandler.h:16
~ServerConnection()
Definition: Server.cc:325
Definition: Runnable.h:23
Definition: TcpListener.h:14
Server(bool spawnThread, int listenPort, unsigned readBufSize=0, unsigned sendBufSize=0)
Definition: Server.cc:24
virtual ~Server()
Definition: Server.cc:75
void sendClientData(NetDat &dat)
Definition: Server.cc:237
virtual void run()
Definition: Server.cc:103