Implements stream API on sockets. Addresses #29