Skip to main content

socket-kit

socket-kit is a utility with concise and more fluent code in socket programming. It handles the job of creating server/client, database operations, transferring data and file over network, as well as OpenCV support.

Server and Client

from socket_kit import socket_kit

server = createServer("192.168.31.138", 9990, clientNum=3)
server = createdLocalhostServer(9990, clientNum=3)
server = createdLocalIPServer(9990, clientNum=3)
client = createClient("192.168.31.138", 9990)

Database

Database Side

from socket_kit import socket_kit

database = socket_kit.MySQLDatabase("database_name", host="localhost" username="root", password="password")

database.createTable("table_name", """
    id INTEGER PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL
""")

database.createUserTabel()
database.createUser("username", "password")
# create user with token is actually normal create user
# username = "_token_"
token = socket_kit.randomToken()
database.createUserWithToken(token)

Server Side

from socket_kit import socket_kit

if socket_kit.userAuthenticate(client, database):
    print("Connected with", address)
else: continue

Client Side

from socket_kit import socket_kit

socket_kit.userLogin(client, "username", "password")
socket_kit.userLoginWithToken(client, "token")
# login in CLI
socket_kit.userLoginCLI(client)

Data Transfer

To concentrate on data transfer, the code below will ignore the concept of server/client, because the sender/receiver can appear at both depending on your requirement.

Sender

from socket_kit import socket_kit

# send pure data
data = b""
message = socket_kit.packData(data)
client.sendall(message)

# send file
message = socket_kit.packFile("movieFile.mp4")
client.sendall(message)

# send frame (OpenCV)
message = socket_cv.packFrame(frame)
client.sendall(message)

Receiver

from socket_kit import socket_kit

# receive pure data
data = socket_kit.receiveData(client)

# receive file
socket_kit.receiveFile("savedFile.mp4", client)

# receive frame (OpenCV)
frame = socket_kit.receiveFrame(client)

Stream Receiver

message = b""
while True:
    # receive stream pure data
    data, message = socket_kit.receiveStreamData(message, client)
    # receive stream frame (OpenCV)
    frame, message = socket_kit.receiveStreamFrame(message, client)

OpenCV

from socket_kit import socket_kit

capture = socket_kit.createCapture()

# default .mp4 with Codec H264
writer = socket_kit.createWriter(capture, "saveMovie.mp4")
socket_kit.saveFrameToMovie(frame, writer)

socket_kit.saveFrameToPhoto(frame, "saveMovie.png")

socket_kit.showFrame("frame", frame)

Metadata

Release files for socket-kit 0.2.1

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

Source distribution (sdist)

Source distribution for socket-kit 0.2.1
File Size Uploaded Provenance Actions
socket_kit-0.2.1.tar.gz 5.1 kB Without provenance Details for socket_kit-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for socket-kit 0.2.1
File Interpreter ABI Platform Actions
socket_kit-0.2.1-py3-none-any.whl Python 3 none any Details for socket_kit-0.2.1-py3-none-any.whl

Total release size: 10.7 kB

Release files / socket_kit-0.2.1.tar.gz

Download URL socket_kit-0.2.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7b77e24c389fb17de8c508fec342bbfa2ec28fea3087c6d0f3fb51eccea7e8c4
BLAKE2b-256 checksum
How to use checksums
0a15e30eae52aac4c7f3df1c6ef81949e4a83b1d6593c3b30c94e6de5e0256cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / socket_kit-0.2.1-py3-none-any.whl

Download URL socket_kit-0.2.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcb6200f7aa371d274a0ccff266c2db55f799e6eca4932659e24ad959c7df3fb
BLAKE2b-256 checksum
How to use checksums
4a01d59e6270a10cd6b300cf6355e9a452a896fb8e49c4d3d9bab59e006dfc78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for socket-kit 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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