refactoring socket.recv()