From e497984db35e69d544d4d8428fda2967ec550b13 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Thu, 15 Sep 2011 06:56:41 -0500 Subject: [PATCH] echo server now accepts `host` in addition to `host:port` as a value for the Host handshake header --- examples/echo_server/echo_server.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/echo_server/echo_server.cpp b/examples/echo_server/echo_server.cpp index c3ee009025..6282e0c671 100644 --- a/examples/echo_server/echo_server.cpp +++ b/examples/echo_server/echo_server.cpp @@ -35,20 +35,21 @@ using boost::asio::ip::tcp; int main(int argc, char* argv[]) { - std::string host = "localhost:5000"; + std::string host = "localhost"; short port = 5000; + std::string full_host; if (argc == 3) { // TODO: input validation? + host = argv[1]; port = atoi(argv[2]); - - - std::stringstream temp; - temp << argv[1] << ":" << port; - - host = temp.str(); } + std::stringstream temp; + + temp << argv[1] << ":" << port; + full_host = temp.str(); + websocketecho::echo_handler_ptr echo_handler(new websocketecho::echo_handler()); try { @@ -61,6 +62,7 @@ int main(int argc, char* argv[]) { // setup server settings server->add_host(host); + server->add_host(full_host); // bump up max message size to maximum since we may be using the echo // server to test performance and protocol extremes. @@ -69,7 +71,7 @@ int main(int argc, char* argv[]) { // start the server server->start_accept(); - std::cout << "Starting echo server on " << host << std::endl; + std::cout << "Starting echo server on " << full_host << std::endl; // start asio io_service.run();