def serve_forever(self): """This method is called when the server is to be run, it will never return, and will only exit on an exception. """ global zc_server try: # If internal Zeroconf support is being used then advertise the server using it if self.zeroconf: import Zeroconf try: local_ip = socket.gethostbyname(currentipaddress()) except: local_ip = socket.gethostbyname(self.address) zc_server = Zeroconf.Zeroconf(bindaddress=local_ip) local_ip = socket.inet_aton(local_ip) zc_server.registerService(Zeroconf.ServiceInfo('_universalctrl._tcp.local.', (str(self.name).replace('.','_') + '._universalctrl._tcp.local.'), address=local_ip, port=self.port, weight=0, priority=0, properties={'server_id' : str(self.uuid)} ), ttl=30 ) self.server.serve_forever() except: self.server.socket.close() raise
def ip_address(self): return currentipaddress()