code: def cmd_port(self, args):
          'handle port selection'
          if len(args) != 1:
              print("Usage: port <number>")
              return
          
          self.port.close()
          self.portnum = int(args[0])
          self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
          self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
          self.port.bind((self.ip, self.portnum))
          self.port.setblocking(0)
          mavutil.set_close_on_exec(self.port.fileno())
          print("Listening for GPS INPUT packets on UDP://%s:%s" % (self.ip, self.portnum)f cmd_port(self, args):
          'handle port selection'
          if len(args) != 1:
              print("Usage: port <number>")
              return
          
          self.port.close()
          self.portnum = int(args[0])
          self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
          self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
          self.port.bind((self.ip, self.portnum))
          self.port.setblocking(0)
          mavutil.set_close_on_exec(self.port.fileno())
          print("Listening for GPS INPUT packets on UDP://%s:%s" % (self.ip, self.portnum))
docs: handle port selection