Consolidated socket reading

Put all the code for reading or writing from sockets into the Util class
as static functions, which are given an Input or OutputStream as
parameters.  This greatly reduced the duplication of code, as every
class had previously had to implement some form of network communication