Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

server-discovery-0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

server_discovery-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file server-discovery-0.1.1.tar.gz.

File metadata

  • Download URL: server-discovery-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for server-discovery-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bc19f3feb6ea3df573de3a47c1f9937616e0626f91c850ad3421ab9e856f35de
MD5 73690d32cde4020efb8ff097c9674525
BLAKE2b-256 a823b76ee738f0870f979ef5abf4f19cd0029e038b27ebac73951ce4b8e296c2

See more details on using hashes here.

Provenance

File details

Details for the file server_discovery-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for server_discovery-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16fe914769bcde1ea112c9082b0fff416ab8f00ac4b91f55b9d40af205f6a190
MD5 03211933b7e8487025a1c93abca6d5f5
BLAKE2b-256 c67599960e410e648402a40073462ab9acd56252475c15be82c9827b6b2e8d15

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page