title: Flush data added to websocket
body: <p>I'm writing a speed test, but i'm having trouble on the client side for uploading.</p>
  <p>I have a the following setup, which basically continues to write data into the socket while a condition is true, and then closes the socket:</p>
  <pre class="lang-dart prettyprint-override"><code>    var ws = await createWebSocket(sb.serverAddress, sb.authToken);
  
      while (condition) {
        var bytes = generateRandomBytes(_BUFFER_SIZE_BYTES);
        ws.add(bytes);
        print('added');
        var megabits = (bytes.length * 8) / 1000000;
        channel.sink.add(megabits);
      }
      await ws.close();
  </code></pre>
  <p>My problem is that I can't work out how to wait for the bytes to be accepted by the underlying buffer. Even if I set <code>_BUFFER_SIZE_BYTES</code> to an huge size it still loops at break neck speed printing out <code>added</code>, where I really want to wait until all the bytes are accepted by the send buffer (having been accepted by the server) before adding a new list of bytes.</p>
  <p>With an http post request you can do: <code>await postReq.flush();</code>, but I don't see any such method for web sockets.</p>