Skip to main content

Cross-platform networking interfaces for Python.

Project description

Data Transfer Protocol for Python

Cross-platform networking interfaces for Python.

Data Transfer Protocol

The Data Transfer Protocol (DTP) is a larger project to make ergonomic network programming available in any language. See the full project here.

Installation

Install the package:

$ python -m pip install dtppy

Creating a server

A server can be built using the Server implementation:

from dtppy import Server


# Called when data is received from a client
def receive(client_id, data):
    # Send back the length of the string
    s.send(len(data), client_id)


# Called when a client connects
def connect(client_id):
    print(f"Client with ID {client_id} connected")


# Called when a client disconnects
def disconnect(client_id):
    print(f"Client with ID {client_id} disconnected")


# Create a server that receives strings and returns the length of each string
s = Server(on_receive=receive, on_connect=connect, on_disconnect=disconnect)
s.start("127.0.0.1", 29275)

Creating a client

A client can be built using the Client implementation:

from dtppy import Client

message = "Hello, server!"


# Called when data is received from the server
def receive(data):
    # Validate the response
    print(f"Received response from server: {data}")
    assert data == len(message)


# Called when the client is disconnected from the server
def disconnected():
    print("Unexpectedly disconnected from server")


# Create a client that sends a message to the server and receives the length of the message
c = Client(on_receive=receive, on_disconnected=disconnected)
# Send the message to the server
c.send(message)

Security

Information security comes included. Every message sent over a network interface is encrypted with Fernet. Key exchanges are performed using a 512-bit RSA key-pair.

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

dtppy-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

dtppy-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file dtppy-0.1.0.tar.gz.

File metadata

  • Download URL: dtppy-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for dtppy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ead0c9f1716c670d42294eacf220e54ae16f22d365de6d0605fa1d1031d294df
MD5 9c8888a8320268423dfb3a1bc66678f3
BLAKE2b-256 3b01610fdc5ab6e8dd25cbd30904e6e4d97035bc3bdf98fe3c6c639eb9a0623c

See more details on using hashes here.

File details

Details for the file dtppy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dtppy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for dtppy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e48dceb1427fc199754479c8922c6e9472931c0973a381461795d81f40389a75
MD5 517dda333e3ed1c5dc33dabe9a2342ae
BLAKE2b-256 f18ce0acfa10caae46d08b4511b83c5b36594bafffeb4fc3a46d0b4e23b2ac2e

See more details on using hashes here.

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