Initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "server.h"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
/* error checking elided for brevity */
|
||||
int fd = ::open("/dev/null", O_WRONLY);
|
||||
::dup2(fd, 2);
|
||||
::close(fd);
|
||||
|
||||
unsigned int port;
|
||||
std::string path;
|
||||
std::string url;
|
||||
|
||||
if (argc == 3)
|
||||
{
|
||||
port = std::atoi(argv[1]);
|
||||
path = std::string(argv[2]);
|
||||
}
|
||||
else if (argc == 4)
|
||||
{
|
||||
port = std::atoi(argv[1]);
|
||||
path = std::string(argv[2]);
|
||||
url = std::string(argv[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Usage: AlarmServer <port> <path> [url]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
boost::asio::io_service io_service;
|
||||
|
||||
server s(io_service, port, path, url);
|
||||
|
||||
io_service.run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user