code: def client_connected_callback(self, reader, writer):
          
          peer = writer.get_extra_info('peername')
          clients.append((reader, writer, peer))
          log.info("Incoming connection from: %s:%s", peer[0], peer[1])
          try:
              while True:
                  data = yield from reader.readline()
                  if not data:
                      break
                  try:
                      line = data.decode().strip()
                  except UnicodeDecodeError:
                      line = '\x00'
  
                  # Workaround for domoticz issue #2816
                  if line[-1] != DELIM:
                      line = line + DELIM
  
                  if valid_packet(line):
                      yield from self.handle_raw_tx_packet(writer, line)
                  else:
                      log.warning(" %s:%s: dropping invalid data: '%s'", peer[0], peer[1], line)
                      pass
          except ConnectionResetError:
              pass
          except Exception as e:
              log.exception(e)
  
          log.info("Disconnected from: %s:%s", peer[0], peer[1])
          writer.close()
          clients.remove((reader, writer, peer))
docs: Handle connected client.