Network Discovery SDK is a Python package that simplifies network service discovery and registration using Zeroconf. It allows you to easily register services on a local network and discover services registered by other devices.
- Simple service registration on local networks
- Automatic IP address detection
- Easy-to-use API for service management
You can install the Network Discovery SDK directly from GitHub using pip:
pip install git+https://github.com/keyur2maru/network-discovery-sdk.git#egg=network_discovery_sdk
Here's a quick example of how to use the Network Discovery SDK:
from network_discovery_sdk import NetworkDiscoverySdk
import time
# Create an instance of NetworkDiscoverySdk
sdk = NetworkDiscoverySdk("MyService", 8080)
try:
# Register the service
sdk.register()
print("Service registered. Press Ctrl+C to stop.")
# Keep the service running
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\nStopping the service...")
finally:
# Unregister the service
sdk.unregister()
print("Service unregistered.")
To register a service:
- Create an instance of
NetworkDiscoverySdk
with a service name and port. - Call the
register()
method to register the service on the network.
sdk = NetworkDiscoverySdk("MyService", 8080)
sdk.register()
To unregister a service:
- Call the
unregister()
method on yourNetworkDiscoverySdk
instance.
sdk.unregister()
Creates a new instance of the Network Discovery SDK.
service_name
(str): The name of your service.service_port
(int): The port number your service is running on.
Registers the service on the local network.
Unregisters the service from the local network.
- Python 3.6+
- zeroconf