Code from Pragmatic Bookshelf Working with TCP Sockets