-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathBrowser.py
More file actions
executable file
·30 lines (26 loc) · 924 Bytes
/
Browser.py
File metadata and controls
executable file
·30 lines (26 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from Zeroconf import *
import socket
class MyListener(object):
def __init__(self):
self.r = Zeroconf()
pass
def removeService(self, zeroconf, type, name):
print "Service", name, "removed"
def addService(self, zeroconf, type, name):
print "Service", name, "added"
print "Type is", type
info = self.r.getServiceInfo(type, name)
print "Address is", str(socket.inet_ntoa(info.getAddress()))
print "Port is", info.getPort()
print "Weight is", info.getWeight()
print "Priority is", info.getPriority()
print "Server is", info.getServer()
print "Text is", info.getText()
print "Properties are", info.getProperties()
if __name__ == '__main__':
print "Multicast DNS Service Discovery for Python Browser test"
r = Zeroconf()
print "1. Testing browsing for a service..."
type = "_http._tcp.local."
listener = MyListener()
browser = ServiceBrowser(r, type, listener)