-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_server.cpp
More file actions
42 lines (29 loc) · 857 Bytes
/
launch_server.cpp
File metadata and controls
42 lines (29 loc) · 857 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
40
41
42
#include "server.hpp"
#include <iostream>
#include <exception>
#include <thread>
#include <boost/asio.hpp>
using std::cout;
using std::endl;
void async_start_server(boost::asio::io_context& io_context, unsigned short &port) {
Server server(io_context, port);
}
int main(int argc, char *argv[]) {
unsigned short server_port;
try {
// can add more error checking for whether the porpt number is valid
if(argc == 2)
server_port = std::stoi(argv[1]);
else if(argc > 2) {
std::cerr << "Invalid amount of arguments. Intended usage: ./launch_server <server_port>" << std::endl;
return 1;
}
boost::asio::io_context io_context;
Server server(io_context, server_port);
io_context.run();
}
catch(std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
}