title: std::streambuf for tcp socket doesn't send data
body: <p>I trying to write buffered std::streambuf for socket. I already wrote unbuffered std::streambuf. I don't understand why buffered streambuf doesn't work. </p>
  
  <pre><code>    Socket::StreamBuf::StreamBuf(const IO &amp;io, tcp::Socket *socket) :
              socket(socket),
              // wb is std::vector&lt;char&gt;
              wb(io.writing)  // set size
      {
          // write
          char_type *buf = wb.data();
          setp(buf, buf + (wb.size() - 1));
  
      };
  
      int Socket::StreamBuf::overflow(int c) {
          if(c != traits_type::eof()) {
              *pptr() = c;
              pbump(1);
  
              if(sync() == -1) return traits_type::eof();
          }
  
          return c;
      }
  
      int Socket::StreamBuf::sync() {
          if(pptr() &amp;&amp; pptr() &gt; pbase()) {
              Int32 sz = Int32(pptr() - pbase());
  
              // int Socket::send(char *data, int size)
              // return sent bytes count
              if (socket-&gt;send(pbase(), sz) == sz) {
                  pbump(-sz);
                  return 0;
              }
          }
  
          return -1;
      }
  </code></pre>