This is closer to what you had before! So my bad for pushing you in the wrong direction.

Overall I think this approach feels right.
1. wait until the stream has budget for the write. Spend that budget.
2. wait until the connection has budget for the write. Spend that budget.
3. wait until the output stream is writable. Write.