SasMNJ - 2012-10-13

The call to receive below will occasionally hang. All interactions are synchronous single threaded. Things work perfectly if I use the alternative sys/socket (non-boost) implementation under the #else.  I must be doing something wrong (I'm very new to boost::asio).

#if 1
namespace bas = boost::asio;

remaining = X (something typically about 5000 bytes of char data)

bas::streambuf b;
  bas::streambuf::mutable_buffers_type bufs = b.prepare(1024);
  while (remaining > 0)
    {
      size_t n = sock_->receive(bufs);   //<---------this blocks/hangs every so often
      remaining -= n;
      for ( bas::buffers_iterator<bas::streambuf::mutable_buffers_type, char>
      it = bas::buffers_begin(bufs); it <  (bas::buffers_begin(bufs) + n); it++ )
  qba.append(*it);
    }
#else //this works perfectly (at least I hit with 100 of thousands of calls)
char buf;
  while (remaining > 0)
    {
      n = read( s, buf, min( sizeof(buf), remaining )  );
      remaining -= n;
      for (int i = 0 ; i < n; i++ )
qba.append(buf_);
    }
#endif_