title: boost asio server-client. Connect between two computers in local area network
body: <p>I wrote a program to synchronize files between two computers in the same local area network, just like the DropBox. It works perfectly to synchronize files from one folder to another folder in the same computer, but when I want to test the program between two computers, it fails to connect to another computer.</p>
  
  <p>my router's IP is 192.168.1.1, one host's IP is 192.168.1.101(host A), another's is 192.168.1.107(host B), they are all in the same local area network. host A runs the client program, host B runs the server program. when host A tries to connect to host B, it fails and displays the message as below:</p>
  
  <blockquote>
    <p>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond</p>
  </blockquote>
  
  <p>I just don't know what's the problem in connecting to another computer in my local area network, and I display the connection code.</p>
  
  <p>client:</p>
  
  <pre><code>bool Send::CheckConnect(boost::asio::ip::tcp::socket&amp; socket)
  {
      boost::asio::io_service io_connect;
      boost::asio::ip::tcp::resolver resolver(io_connect);
      boost::asio::ip::tcp::resolver::query query("192.168.1.107", "6873");
      boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query), end;
      boost::system::error_code error_connect;
  
      unsigned short count = 0;
      while( count &lt; 3 )
      {
          ++count;
          if( boost::asio::connect(socket, endpoint_iterator, error_connect) != end )
              return true;                         
      }
      std::cout&lt;&lt;boost::system::system_error(error_connect).what()&lt;&lt;std::endl;
      return false;
  }
  </code></pre>
  
  <p>server:</p>
  
  <pre><code>boost::asio::io_service io_sev;
  boost::asio::ip::tcp::acceptor accept_server( io_sev, boost::asio::ip::tcp::endpoint
      (boost::asio::ip::tcp::v4(), 6873) );
  unsigned count = 0;
  boost::asio::ip::tcp::socket socket_server(io_sev);
  </code></pre>