28 #include "SystemHandler.h"
30 #include "../net/ServerHandler.h"
31 #include "../net/server_protocol.h"
36 typedef enum {DEFAULT, RUNNING, STOPPED} ServerState;
38 extern sig_atomic_t currentServerState;
39 const std::string DEFAULT_DATA_DIR =
"database";
40 const std::string DEFAULT_CONF_DIR =
"conf";
41 const std::string VERSION =
"1.0.0";
43 struct NetworkThreadArgs;
70 static const net::Port DEFAULT_PORT = 4444;
71 static const int POSIX_DSS_THREAD_TIMER = 30;
72 static const int WIN32_DSS_THREAD_TIMER = 30000;
74 std::string dataDirectory;
75 std::string confDirectory;
89 void setSignalHandler();
92 void createDssThread();
98 void createNetworkThread(
int connectedSocket);
147 void printUsage(
const char *program);
150 void printInitialMessage();
153 static Server *getContext();
156 #if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
158 static unsigned int __stdcall win32DssThread(
void *args);
159 static unsigned int __stdcall win32NetworkThread(
void *args);
160 static BOOL WINAPI consoleHandler(DWORD signal);
162 std::map<unsigned int, HANDLE> networkThreadHandles;
163 std::map<unsigned int, NetworkThreadArgs*> networkThreadArgs;
164 HANDLE dssThreadHandle;
166 Event dssThreadEvent;
169 static void *posixDssThread(
void *args);
170 static void *posixNetworkThread(
void *args);
171 static void signalHandler(
int signal);
173 std::map<pthread_t, NetworkThreadArgs*> networkThreads;
174 pthread_t dssThreadId;
bool checkArguments(int argc, char **argv)
Definition: Server.cpp:68
net::SocketState threadState
Definition: Server.h:192
An INSERT request message.
Definition: server_protocol.h:67
A SEARCH request message.
Definition: server_protocol.h:114
SocketState
Definition: net.h:44
A Mutex object.
Definition: sync.h:40
void start()
Definition: Server.cpp:156
A Data Set (DS) is an instance of a DSS and is defined by a SetDescriptor and a set of DataItems...
Definition: DataSet.h:36
Definition: SystemHandler.h:38
Server * server
Definition: Server.h:193
System main class, implementing the server side.
Definition: Server.h:50
A Read-Write lock object.
Definition: sync.h:69
Server side of the SimDB socket interface. This class provides the server side functions to simplify ...
Definition: ServerHandler.h:38
A GET or REMOVE request message.
Definition: server_protocol.h:94