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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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