Make PhutilSocketChannel work better for channels with separate I/O
Summary:
Currently, all uses of PhutilSocketChannel are protocol-based or terminate the read and write socket at the same time (e.g., when the other side terminates).
However, when receiving an SSH request, we sometimes to read all of stdin until the socket hits EOF and closes, but then may still want to write a response out. Allow PhutilSocketChannel to close just half of the channel (read or write) without also closing the other half. Also, provide specific tests for a channel being open for reading and writing.
Also, implement PhutilMetricsChannel, which just counts bytes that go through it. Eventually, this will count I/O over SSH and feed into some system which keeps track of how much stuff we're using.
Test Plan: See next diff; implemented SSH glue on top of this.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T603, T550
Differential Revision: https://secure.phabricator.com/D4228