A fancy networking library which supports both the protocols (UDP support WIP); and makes it hard to shoot yourself in the foot.
Project description
pydatanet, a lightweight easy-to-use yet intuitive networking library, built on top of plain-vanilla sockets.
PyDataNet 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 pydatanet
from pydatanet.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 pydatanet
from pydatanet.client import Client, ClientType # do not mistake for pydatanet.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
autoPollto False and hook upClient._connectto 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydatanet-0.1.1rc7.tar.gz.
File metadata
- Download URL: pydatanet-0.1.1rc7.tar.gz
- Upload date:
- Size: 7.6 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.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a2e868a8f97636445f0a7f29a485f035c4b7b5440a82ee9e53f789596046c05
|
|
| MD5 |
3296daac558f3f40f730012772e2dcb8
|
|
| BLAKE2b-256 |
d55119eb2ab04d82d50e97d78e9ec364b33e4d24ebd22ad6a11b63b63c1b8d35
|
File details
Details for the file pydatanet-0.1.1rc7-py3-none-any.whl.
File metadata
- Download URL: pydatanet-0.1.1rc7-py3-none-any.whl
- Upload date:
- Size: 7.1 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.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53b2c84c4658947b838fd6f9348f48baa98431afd690ec8c504a6d3bf4ae79a1
|
|
| MD5 |
0105816d8ac847cf89bc0bd1ab08ddeb
|
|
| BLAKE2b-256 |
d5b00cd91db047cbb4f5f4f78b913ddecd3af1f1e747dec70c6da765c80c2073
|