Portability: Fix assumption about read() and write() on connecting sockets