title: boost:asio async_receive_from behaves synchronously
body: <p>In the code below, the asynch_receive_from behaves synchronously. It doesn't come back until data is received. A look at the log at the end indicates this. This may not be that
  obvious at first because there's a fairly high rate of data coming in. But when there's not data, only one second heartbeat messages, the return out of these asynch calls is on the order of one second as well. </p>
  
  <p>The question is why aren't these asynch calls returning immediately (within a few micros), and with no bytes read?</p>
  
  <p>I thought that maybe having other items in the run queue would facilitate the process, thinking that if there's nothing on the queue to run that io_services would turn the asynch function into a synch function since there's nothing else for it to do yet. But I added the 2 posts ahead of the asynch call which, I would believe, put something into the run queue ahead of the asynch call. But that didn't seem to make a difference.</p>
  
  <p>Any help would be appreciated. I am new to the boost::asio library.</p>
  
  <pre><code>void receiver::handle_receive_from(const boost::system::error_code&amp; error,
        size_t bytes_recvd)
  {
      static char logBuf[128];    
      string dStr;
      int rVal;
      unsigned int seqNo;
  
      sprintf_s(logBuf, sizeof(logBuf), "BytesRead:%d", bytes_recvd);
      MyLog(logBuf);
      MyLog("1"); 
      MyLog("2");
      iosP-&gt;post(boost::bind(&amp;receiver::postTestHandler, this));
      iosP-&gt;post(boost::bind(&amp;receiver::postTestHandler, this));
      socket_.async_receive_from(
                  boost::asio::buffer(data_, max_length), sender_endpoint_,
                  boost::bind(&amp;receiver::handle_receive_fromTwo, this,
                  boost::asio::placeholders::error,
                  boost::asio::placeholders::bytes_transferred));     
  
      MyLog("3");
  
  }
  
  void receiver::handle_receive_fromTwo(const boost::system::error_code&amp; error, size_t bytes_recvd)
  {
      char logBuf[128];
  
      sprintf_s(logBuf, sizeof(logBuf), "Two BytesRead:%d", bytes_recvd);
      MyLog(logBuf);
  
      MyLog("1-Two"); 
      MyLog("2-Two");
      iosP-&gt;post(boost::bind(&amp;receiver::postTestHandler, this));
      iosP-&gt;post(boost::bind(&amp;receiver::postTestHandler, this));
      socket_.async_receive_from(
                  boost::asio::buffer(data_, max_length), sender_endpoint_,
                  boost::bind(&amp;receiver::handle_receive_from, this,
                  boost::asio::placeholders::error,
                  boost::asio::placeholders::bytes_transferred));         
  
  
      MyLog("3-Two");
  
  }
  
  void receiver::postTestHandler()
  {   
      int count(0);
      MyLog("***postTestHandler entry***");
      printf("***postTestHandler entry***\n");
      printf("Exiting postTestHandler\n");
      MyLog("Exiting postTestHandler");
  }
  </code></pre>
  
  <p>Log snippet</p>
  
  <pre><code>[11:57:51.653647]BytesRead:16
  [11:57:51.653660]1
  [11:57:51.653662]2
  [11:57:51.653692]3
  [11:57:51.653697]***postTestHandler entry***
  [11:57:51.654310]Exiting postTestHandler
  [11:57:51.654315]***postTestHandler entry***
  [11:57:51.654657]Exiting postTestHandler
  [11:57:51.727494]Two BytesRead:67
  [11:57:51.727503]1-Two
  [11:57:51.727506]2-Two
  [11:57:51.727524]3-Two
  [11:57:51.727529]***postTestHandler entry***
  [11:57:51.728060]Exiting postTestHandler
  [11:57:51.728065]***postTestHandler entry***
  [11:57:51.728407]Exiting postTestHandler
  [11:57:52.438916]BytesRead:67
  [11:57:52.438929]1
  [11:57:52.438932]2
  [11:57:52.438961]3
  [11:57:52.438965]***postTestHandler entry***
  [11:57:52.439568]Exiting postTestHandler
  [11:57:52.439573]***postTestHandler entry***
  [11:57:52.439914]Exiting postTestHandler
  [11:57:52.581333]Two BytesRead:67
  [11:57:52.581346]1-Two
  [11:57:52.581349]2-Two
  [11:57:52.581375]3-Two
  [11:57:52.581381]***postTestHandler entry***
  [11:57:52.582011]Exiting postTestHandler
  [11:57:52.582016]***postTestHandler entry***
  [11:57:52.582358]Exiting postTestHandler
  [11:57:52.582364]BytesRead:67
  [11:57:52.582367]1
  [11:57:52.582370]2
  [11:57:52.582377]3
  [11:57:52.582381]***postTestHandler entry***
  [11:57:52.582717]Exiting postTestHandler
  [11:57:52.582722]***postTestHandler entry***
  [11:57:52.583055]Exiting postTestHandler
  [11:57:52.583061]Two BytesRead:67
  [11:57:52.583064]1-Two
  [11:57:52.583066]2-Two
  [11:57:52.583077]3-Two
  [11:57:52.583081]***postTestHandler entry***
  [11:57:52.583418]Exiting postTestHandler
  [11:57:52.583423]***postTestHandler entry***
  [11:57:52.583755]Exiting postTestHandler
  [11:57:52.616525]BytesRead:67
  [11:57:52.616531]1
  [11:57:52.616533]2
  [11:57:52.616549]3
  [11:57:52.616553]***postTestHandler entry***
  [11:57:52.617015]Exiting postTestHandler
  [11:57:52.617020]***postTestHandler entry***
  [11:57:52.617362]Exiting postTestHandler
  </code></pre>