title: Applying a timeout to UDP call receive_from in ASIO
body: <p>I have the following bit of ASIO code, that synchronously reads UDP packets. The problem is if no data packets of the given size have arrived in a given time frame  (30 seconds) I'd like the recieve_from function to return with some kind of error to specif icy timeout.</p>
  
  <pre><code>for (;;)
  {
    boost::array&lt;char, 1000&gt; recv_buf;
    udp::endpoint remote_endpoint;
    asio::error_code error;
  
    socket.receive_from(asio::buffer(recv_buf),   // &lt;-- require timeout
        remote_endpoint, 0, error);
  
    if (error &amp;&amp; error != asio::error::message_size)
      throw asio::system_error(error);
  
    std::string message = make_daytime_string();
  
    asio::error_code ignored_error;
    socket.send_to(asio::buffer(message),
        remote_endpoint, 0, ignored_error);
  }
  </code></pre>
  
  <p>Looking at the documentation non of the UDP oriented calls support a time-out mechanism.</p>
  
  <p>What is the correct way (also portable if possible) for having a time-out with syncronous UDP calls in ASIO?</p>