'Read data from the socket as if it were a file.'

def read(self, size=4096):

    if (self._sock is None):
        return None
    while True:
        try:
            data = self._sock.recv(size)
            break
        except socket.error as serr:
            if (serr.errno != errno.EINTR):
                raise
    if (data is not None):
        return data
