moving socket logic to an independant class for client and server.