title: Simple server/client boost example not working
body: <p>Learning boost, and compiled their daytime server client <a href="http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/examples.html" rel="nofollow noreferrer">example</a>. Since I cant use port 13 that is in the example I only changed the port numbers in the server and client example. Server runs fine, but the client doesnt connect it seems, and no error is given.</p>
  
  <p>Input data for the client is "127.0.0.1".</p>
  
  <p>Server:</p>
  
  <pre><code>#include &lt;ctime&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;boost/asio.hpp&gt;
  
  using boost::asio::ip::tcp;
  
  std::string make_daytime_string()
  {
    using namespace std; // For time_t, time and ctime;
    time_t now = time(0);
    return ctime(&amp;now);
  }
  
  int main()
  {
    try
    {
      boost::asio::io_service io_service;
  
      tcp::endpoint endpoint(tcp::v4(), 8087);
      tcp::acceptor acceptor(io_service, endpoint);
  
      for (;;)
      {
        tcp::iostream stream;
        acceptor.accept(*stream.rdbuf());
        stream &lt;&lt; "test" &lt;&lt; make_daytime_string();
      }
    }
    catch (std::exception&amp; e)
    {
      std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
    }
  
    return 0;
  }
  </code></pre>
  
  <p>And the client:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;boost/asio.hpp&gt;
  
  using boost::asio::ip::tcp;
  
  int main(int argc, char* argv[])
  {
    try
    {
      if (argc != 2)
      {
        std::cerr &lt;&lt; "Usage: daytime_client &lt;host&gt;" &lt;&lt; std::endl;
        return 1;
      }
  
      tcp::iostream s(argv[1], 8087);
      std::string line;
      std::getline(s, line);
      std::cout &lt;&lt; line &lt;&lt; std::endl;
    }
    catch (std::exception&amp; e)
    {
      std::cout &lt;&lt; "Exception: " &lt;&lt; e.what() &lt;&lt; std::endl;
    }
  
    return 0;
  }
  </code></pre>