title: Boost ASIO UDP client async_receive_from calls handler even when there are no incoming messages
body: <p>I've modified the UDP client code from Boost daytime client tutorial into the following:</p>
  
  <pre><code>class UDPClient
  {
  public:
      udp::socket* socket;
      udp::endpoint* receiver_endpoint;
      boost::array&lt;char, 1024&gt; recv_buffer;
  
      UDPClient();
      void do_receive();
      void handle_receive(const boost::system::error_code&amp; error, size_t);
  };
  
  UDPClient::UDPClient()
  {
      boost::asio::io_service io_service;
  
      udp::resolver resolver(io_service);
      udp::resolver::query query(udp::v4(), "127.0.0.1", "8888");
      receiver_endpoint = new udp::endpoint(*resolver.resolve(query));
  
      socket = new udp::socket(io_service);
      socket-&gt;open(udp::v4());
  
      do_receive();
  
      while (true)
      {
          io_service.poll();
          Sleep(1);
      }
  }
  
  void UDPClient::do_receive()
  {
      socket-&gt;async_receive_from(boost::asio::buffer(recv_buffer), *receiver_endpoint,
                                 boost::bind(&amp;UDPClient::handle_receive, this,
                                 boost::asio::placeholders::error,
                                 boost::asio::placeholders::bytes_transferred));
  }
  
  void UDPClient::handle_receive(const boost::system::error_code&amp; error, size_t bytes_transferred)
  {
      cout &lt;&lt; "ulala" &lt;&lt; endl;
  
      if (!error || error == boost::asio::error::message_size)
          do_receive();
  }
  </code></pre>
  
  <p>If all works out according to plan, "ulala" would only be printed if there is an incoming message. However that is not the case here... The handler gets called instantaneously and "ulala" is printed regardless of whether there is an incoming message. I've tried a few different things: swapping io_service.poll() with io_service.run() and io_service.run_one(), as well as removing Sleep(1), but none of those changes have any effect on the problem. What should I do?</p>
  
  <p>Thanks in advance!</p>