Skip to main content

A small example package

Project description

pysyn, a lightweight easy-to-use yet intuitive networking library, built on top of plain-vanilla sockets.

PySyn does most of the tedious hard labour for you and removes the pain out of socket programming. It supports TCP and UDP (UDP WIP).

It features:

  • Object serialization into bytes and de-serialization into the literal object through pickle so you don't have to worry about converting your objects into sendable bytes.
  • An easy to understand client/server concept.
  • Even a beginner can start learning it and get a small hang of how sockets work, hence, great if you don't want to directly dip your toes into sockets; but I would still recommend learning sockets as it can be crucial whilst debugging errors.

Some boilerplate

BASIC SERVER:

import pysyn
from pysyn.server import Server, ServerType

def onPacketSend(sender, data):
    print(f"{sender.getIp()} sent me this!: {data}")

myServer = Server('localhost', 5050, ServerType.TCP)
myServer.on_recv_bind(onPacketSend)
myServer.connect()

BASIC CLIENT:

import pysyn
from pysyn.client import Client, ClientType # do not mistake for pysyn.server.client!

def myFuncOnReceiveTCP(data_decoded):
    print(f"I got some data: {data_decoded}")

class myFancyClass():
    def __init__(self, doLikePizza: bool = False):
        self.doLikePizza = doLikePizza

c = Client(ClientType.TCP)
c.hook_tcp_recv(myFuncOnReceiveTCP)
c.connect("localhost", 5050)
c.send(
    {
        "foo": "bar",
        "math": 55,
        "myNumbers": [0, 1, 2, 3, 4, 5],
        "myClass": myFancyClass(True)
    }
)

and the best part, your data will reach the other side just in the same shape! Now, isn't that convenient?

EXTRA FEATURES

  • Incredibly foolproof; sockets created auto-close upon the program stopping so you don't shoot yourself in the foot. Even if THAT fails, it will auto-reuse the socket.
  • You can supply the extra argument autoPoll to False and hook up Client._connect to your task managing system if you want to (if you want to control the frequency of heartbeats/polls).

CLOSING NOTES

  • Please report vulnerabilites, bugs, suggestions and performance issues in the issues tab. That would be greatly appreciated.
  • This is NOT a full time project; this is just something I made because PyEnet was extremely imperformant and other libraries did not satisfy my needs. I will not dedicate my entire time to this.
  • Check out TUO; a game I am working on, that was the drive to make this library. (https://discord.gg/2ZycjAA)
  • I do not appreciate any illegal tomfoolery, better known as felonies to be committed using my library. I am not responsible for any damage conducted using this library.
  • I swear I shall not add any protestware or malware. If you see someone adding such things, my account will have been likely hijacked. I do not like mixing politics into programming. (cough cough, @RIAEvangelist)

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

pydatanet-0.0.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pydatanet-0.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

pydatanet-0.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pydatanet-0.0.1.tar.gz.

File metadata

  • Download URL: pydatanet-0.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pydatanet-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b7cae064597be270876fade892091eea63257fe7876afbb2cafa7dd93fd323b2
MD5 ab840ff0337a80c15913b2e3feefb3c3
BLAKE2b-256 89e7fe1d6b4a5f93d81760d5730186a171fcfb99d8ff32043af9f555f10b0874

See more details on using hashes here.

File details

Details for the file pydatanet-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pydatanet-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pydatanet-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2ce2962e4fbeb7d36c939976a374e13562c735af3cae7cf008e6eef032be28ed
MD5 bf564eab664214566b878e7ebc2c05fb
BLAKE2b-256 aba715f978c99fb2e88f54826b651e7098851b93ddc2501c1f4574e47fc5c27e

See more details on using hashes here.

File details

Details for the file pydatanet-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pydatanet-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pydatanet-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bbd49bddffcfadd1ff75cfe5180a29331f250835df8a96ecfa14c9cba99f4e5
MD5 ee3397176a81d4d032fc669290949f65
BLAKE2b-256 42a48b27ffd3081297f2896efadfefcf70f2e0f374912ff9aee297b66e517683

See more details on using hashes here.

Supported by

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