Automatically find your server(s) by port on the local network
Project description
server-discovery
Python library for automatically finding your server(s) by port on the local network
Install
Just do pip install server-discovery
Usage
On the server side start the response mainloop with your chosen ports:
import server_discovery
server_discovery.server_responseloop(7491, 7492)
The clients can then search for servers using those same ports, and devices will be returned in a generator as they are found:
import server_discovery
for server in server_discovery.search_for_servers(7491, 7492):
print(server)
The server calls out on all available interfaces and the client gets the relevant address, so this still works when using multiple (virtual) networks (like when in a Docker container).
What's returned?
Servers are returned as ServerInfo objects (uses Pydantic models) that include the ip address and persistent device id of the server, so the same server can be found even if the device's ip address changes.
You can also pass a device name or the service version as optional info to be sent from the server.
class ServerInfo:
ip_address: str
device_id: int
device_name: Optional[str]
service_version: Optional[str]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for server_discovery-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16fe914769bcde1ea112c9082b0fff416ab8f00ac4b91f55b9d40af205f6a190 |
|
MD5 | 03211933b7e8487025a1c93abca6d5f5 |
|
BLAKE2b-256 | c67599960e410e648402a40073462ab9acd56252475c15be82c9827b6b2e8d15 |