1562 # Test a few module features, including service registration, service |
1564 # Test a few module features, including service registration, service |
1563 # query (for Zoe), and service unregistration. |
1565 # query (for Zoe), and service unregistration. |
1564 |
1566 |
1565 |
1567 |
1566 if __name__ == '__main__': |
1568 if __name__ == '__main__': |
1567 print "Multicast DNS Service Discovery for Python, version", __version__ |
1569 print("Multicast DNS Service Discovery for Python, version", __version__) |
1568 r = Zeroconf() |
1570 r = Zeroconf() |
1569 print "1. Testing registration of a service..." |
1571 print("1. Testing registration of a service...") |
1570 desc = {'version': '0.10', 'a': 'test value', 'b': 'another value'} |
1572 desc = {'version': '0.10', 'a': 'test value', 'b': 'another value'} |
1571 info = ServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.", socket.inet_aton("127.0.0.1"), 1234, 0, 0, desc) |
1573 info = ServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.", socket.inet_aton("127.0.0.1"), 1234, 0, 0, desc) |
1572 print " Registering service..." |
1574 print(" Registering service...") |
1573 r.registerService(info) |
1575 r.registerService(info) |
1574 print " Registration done." |
1576 print(" Registration done.") |
1575 print "2. Testing query of service information..." |
1577 print("2. Testing query of service information...") |
1576 print " Getting ZOE service:", str(r.getServiceInfo("_http._tcp.local.", "ZOE._http._tcp.local.")) |
1578 print(" Getting ZOE service:", str(r.getServiceInfo("_http._tcp.local.", "ZOE._http._tcp.local."))) |
1577 print " Query done." |
1579 print(" Query done.") |
1578 print "3. Testing query of own service..." |
1580 print("3. Testing query of own service...") |
1579 print " Getting self:", str(r.getServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local.")) |
1581 print(" Getting self:", str(r.getServiceInfo("_http._tcp.local.", "My Service Name._http._tcp.local."))) |
1580 print " Query done." |
1582 print(" Query done.") |
1581 print "4. Testing unregister of service information..." |
1583 print("4. Testing unregister of service information...") |
1582 r.unregisterService(info) |
1584 r.unregisterService(info) |
1583 print " Unregister done." |
1585 print(" Unregister done.") |
1584 r.close() |
1586 r.close() |