Skip to main content

peerpy 1.0.0

Discover and connect every device running python on a local network via TCP!

This module provides a high-level API for discovering and connecting multiple devices on a local network, without the headache of implementing python's built-in socket module!

Installation

pip install peerpy

Quick tour

Connecting two devices running python is as easy, reliable and painless as 8 lines of code!

Start by importing the Peer class, which automatically detects your device's local IP and run a socket server, listening on a given port:

from peerpy import Peer

Start a peer object on the listening device:

with Peer(port=54865) as peer:
    # let the program run until CTRL+C
    while True:
        time.sleep(1.)

Connect your second device to your listening device:

with Peer(port=12152) as peer:
    connection = peer.connect("192.168.0.2:54865")

    if connection:
        connection.send(f"Hello world from {peer.address_name}!")

You can even add handlers which are executed on a separate thread on specific events, such as:

def set_connection_handler(connection):
    connection.set_handler("data", lambda data: print(data))

with Peer(handlers={
    # called when socket server is listening
    "listen": lambda peer: print(peer.address_name),
    # called when socket has established a connection
    "connection": set_connection_handler,
    # called when socket server has stopped
    "stop": lambda peer: print("Peer stopped!")
}) as peer:

For more details on handlers and connections, please consider reading the documentation.

Examples

To begin with this module, please consider reading the examples given on this repository.

Documentation

For further documentation, please Read The Docs!

Release files for peerpy 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for peerpy 1.2.2
File Size Uploaded
peerpy-1.2.2.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for peerpy 1.2.2
File Interpreter ABI Platform
peerpy-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / peerpy-1.2.2.tar.gz

Download URL peerpy-1.2.2.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a82834af41e38732ddf1541f3f1ef0936bdfd3ac99433c16df260947da06432a
BLAKE2b-256 checksum
How to use checksums
6b6539cb310a2af9ef22496d20e12a05bb1dd9fb3ac6e28f0ce04b538960e283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / peerpy-1.2.2-py3-none-any.whl

Download URL peerpy-1.2.2-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8dac330e23391b2942da75c59e08db7ea20605cdb2f98724420baee7f22c700
BLAKE2b-256 checksum
How to use checksums
e90476023d54f683086981513362f414ebbb75bd34c315cd995f73211c5c9efb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page