Fix lexical_cast handling of port command line argument.
This commit is contained in:
parent
c7364276d9
commit
012e97b5f0
@ -17,7 +17,7 @@ int main(int argc, char* argv[])
|
|||||||
std::cerr << "Usage: http_server <port> <doc_root>\n";
|
std::cerr << "Usage: http_server <port> <doc_root>\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
short port = boost::lexical_cast<short>(argv[1]);
|
unsigned short port = boost::lexical_cast<unsigned short>(argv[1]);
|
||||||
std::string doc_root = argv[2];
|
std::string doc_root = argv[2];
|
||||||
|
|
||||||
// Block all signals for background thread.
|
// Block all signals for background thread.
|
||||||
@ -51,6 +51,10 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
std::cerr << "asio error: " << e << "\n";
|
std::cerr << "asio error: " << e << "\n";
|
||||||
}
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << "exception: " << e.what() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ int main(int argc, char* argv[])
|
|||||||
std::cerr << "Usage: http_server <port> <doc_root>\n";
|
std::cerr << "Usage: http_server <port> <doc_root>\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
short port = boost::lexical_cast<short>(argv[1]);
|
unsigned short port = boost::lexical_cast<unsigned short>(argv[1]);
|
||||||
std::string doc_root = argv[2];
|
std::string doc_root = argv[2];
|
||||||
|
|
||||||
// Initialise server.
|
// Initialise server.
|
||||||
@ -50,6 +50,10 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
std::cerr << "asio error: " << e << "\n";
|
std::cerr << "asio error: " << e << "\n";
|
||||||
}
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << "exception: " << e.what() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user