Implement most of the networking. Need to catch connection closed exception.