main.cpp 979 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // main.cpp
  3. // ~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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. #include <iostream>
  11. #include <string>
  12. #include <boost/asio.hpp>
  13. #include "server.hpp"
  14. int main(int argc, char* argv[])
  15. {
  16. try
  17. {
  18. // Check command line arguments.
  19. if (argc != 4)
  20. {
  21. std::cerr << "Usage: http_server <address> <port> <doc_root>\n";
  22. std::cerr << " For IPv4, try:\n";
  23. std::cerr << " receiver 0.0.0.0 80 .\n";
  24. std::cerr << " For IPv6, try:\n";
  25. std::cerr << " receiver 0::0 80 .\n";
  26. return 1;
  27. }
  28. // Initialise the server.
  29. http::server::server s(argv[1], argv[2], argv[3]);
  30. // Run the server until stopped.
  31. s.run();
  32. }
  33. catch (std::exception& e)
  34. {
  35. std::cerr << "exception: " << e.what() << "\n";
  36. }
  37. return 0;
  38. }