title: boost asio timeout
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/291871/how-to-set-a-timeout-on-blocking-sockets-in-boost-asio">How to set a timeout on blocking sockets in boost asio?</a>  </p>
  </blockquote>
  
  
  
  <p>I read some of the entries before about the timeout but I don't understand.</p>
  
  <p>I want a defined timeout for the connection.
  the connect code looks like:</p>
  
  <pre><code>try{
    boost::asio::ip::tcp::resolver              resolver(m_ioService);
    boost::asio::ip::tcp::resolver::query       query(link.get_host(), link.get_scheme());
    boost::asio::ip::tcp::resolver::iterator    endpoint_iterator = resolver.resolve(query);
    boost::asio::ip::tcp::resolver::iterator    end;
    boost::system::error_code                   error   =   boost::asio::error::host_not_found;
  
    while (error &amp;&amp; endpoint_iterator != end)
     {
      m_socket.close();
      m_socket.connect(*endpoint_iterator++, error);
     }
  }
  </code></pre>
  
  <p>also I want a read timeout.</p>
  
  <p>I use <code>boost::asio::read_until(m_socket, response, "\r\n");</code> for read the header.</p>
  
  <p>is it possible to set SIMPLE a timeout?</p>