1 // 2 // main.cpp 3 // ~~~~~~~~ 4 // 5 // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 // 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 // 10 11 #include <iostream> 12 #include <string> 13 #include <boost/asio.hpp> 14 #include <boost/bind/bind.hpp> 15 #include <boost/lexical_cast.hpp> 16 #include "server.hpp" 17 main(int argc,char * argv[])18int main(int argc, char* argv[]) 19 { 20 try 21 { 22 // Check command line arguments. 23 if (argc != 5) 24 { 25 std::cerr << "Usage: http_server <address> <port> <threads> <doc_root>\n"; 26 std::cerr << " For IPv4, try:\n"; 27 std::cerr << " receiver 0.0.0.0 80 1 .\n"; 28 std::cerr << " For IPv6, try:\n"; 29 std::cerr << " receiver 0::0 80 1 .\n"; 30 return 1; 31 } 32 33 // Initialise the server. 34 std::size_t num_threads = boost::lexical_cast<std::size_t>(argv[3]); 35 http::server3::server s(argv[1], argv[2], argv[4], num_threads); 36 37 // Run the server until stopped. 38 s.run(); 39 } 40 catch (std::exception& e) 41 { 42 std::cerr << "exception: " << e.what() << "\n"; 43 } 44 45 return 0; 46 } 47