Take advantage of StreamReaderProtocol.

This is a step towards supporting flow control.

Refactor connection termination to better follow the specification:
close the TCP connection properly with shutdown() then close().
Add flow control. Fix #10.

Invoke drain() after each write.