import socket import threading import time class MasterServer: def __init__(self, server): self.server = server self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.masterserverip = "gckms.no-ip.org" self.masterserverport = 27900 def register_and_run(self): register_thread = threading.Thread(target=self._register) register_thread.start() return register_thread def _register(self): while True: self.socket.sendto(("0"+str(self.server.listen_port)).encode("ascii"), (self.masterserverip, self.masterserverport)) time.sleep(120)