forked from Sys-KU/DeepPlan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
39 lines (34 loc) · 758 Bytes
/
server.cpp
File metadata and controls
39 lines (34 loc) · 758 Bytes
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
#include <server/server.h>
#include <signal.h>
class InterruptException : public std::exception
{
public:
InterruptException(int s) : S(s) {}
int S;
};
void sig_to_exception(int s)
{
throw InterruptException(s);
}
int main(int argc, char** argv) {
{
// setupt handling interrupt
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = sig_to_exception;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
}
Server* server;
try {
server = new Server(DEFAULT_PORT);
server->run();
}
catch(InterruptException& e) {
server->shutdown();
}
catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << "\n";
}
return 0;
}