summaryrefslogtreecommitdiff
path: root/examples/registration.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/registration.py')
-rwxr-xr-xexamples/registration.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/registration.py b/examples/registration.py
new file mode 100755
index 0000000..293047f
--- /dev/null
+++ b/examples/registration.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+""" Example of announcing a service (in this case, a fake HTTP server) """
+
+import socket
+
+from zeroconf import raw_input, ServiceInfo, Zeroconf
+
+desc = {'path': '/~paulsm/'}
+
+info = ServiceInfo("_http._tcp.local.",
+ "Paul's Test Web Site._http._tcp.local.",
+ socket.inet_aton("10.0.1.2"), 80, 0, 0,
+ desc, "ash-2.local.")
+
+zeroconf = Zeroconf()
+print("Registration of a service...")
+zeroconf.registerService(info)
+try:
+ raw_input("Waiting (press Enter to exit)...")
+finally:
+ print("Unregistering...")
+ zeroconf.unregisterService(info)
+ zeroconf.close()