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]
Metadata
Release files for server-discovery 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| server-discovery-0.1.1.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| server_discovery-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / server-discovery-0.1.1.tar.gz
| Download URL | server-discovery-0.1.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc19f3feb6ea3df573de3a47c1f9937616e0626f91c850ad3421ab9e856f35de
|
|
BLAKE2b-256 checksum How to use checksums |
a823b76ee738f0870f979ef5abf4f19cd0029e038b27ebac73951ce4b8e296c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / server_discovery-0.1.1-py3-none-any.whl
| Download URL | server_discovery-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16fe914769bcde1ea112c9082b0fff416ab8f00ac4b91f55b9d40af205f6a190
|
|
BLAKE2b-256 checksum How to use checksums |
c67599960e410e648402a40073462ab9acd56252475c15be82c9827b6b2e8d15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|