'Read up to length bytes from receive buffer
(defaults to all)'

def read(self, length=None):

    if (length is None):
        length = len(self.receive_buf)
    r = self.receive_buf[:length]
    self.receive_buf = self.receive_buf[length:]
    return r
