code: def socket_reader(connection: socket, buffer_size: int = 1024):
      
      while connection is not None:
          try:
              buffer = connection.recv(buffer_size)
              # no output
              if not len(buffer):
                  raise ConnectionAbortedError
          except ConnectionAbortedError:
              # socket closed
              print('connection aborted')
              connection.close()
              yield None
          except OSError:
              # still operate connection after it was closed
              print('socket closed')
              connection.close()
              yield None
          else:
              yield buffer
docs: read data from adb socket