Skip to content

Instantly share code, notes, and snippets.

@CoMPaTech
Created June 17, 2020 17:47
Show Gist options
  • Save CoMPaTech/334d4823ed81b82a5a3e4fe6b59cd473 to your computer and use it in GitHub Desktop.
Save CoMPaTech/334d4823ed81b82a5a3e4fe6b59cd473 to your computer and use it in GitHub Desktop.
zeroconf discovery
from zeroconf import ServiceBrowser, Zeroconf
class MyListener:
def remove_service(self, zeroconf, type, name):
print("Service %s removed\n" % (name,))
def add_service(self, zeroconf, type, name):
info = zeroconf.get_service_info(type, name)
print("Service %s added, service info: %s\n" % (name, info))
zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)
try:
input("Press enter to exit...\n\n")
finally:
zeroconf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment