tej-protoc v1
tej-protoc v1 is a implementation of custom TEJ protocol. It is a full duplex protocol.
This protocol can be used for sending large files and messages faster.
Installation
pip install tej-protoc
Diagram
+-------------------------------------------------------------------+
| TEJ Protocol v1 |
+-------------------------------------------------------------------+
| Status Byte | |
|--------------------------------| Protocol Version |
| Status bit | Custom status | 8 bits |
| (1 bit) | (7 bits) | |
+-------------------------------------------------------------------+
| Number of files |
| (64 bits) |
+-------------------------------------------------------------------+
| 'n' File name length | 'n' Actual file name |
| (16 bits) | (from 'n' filename length) |
+-------------------------------------------------------------------+
| 'n' file length | 'n' Actual file data |
| (64 bits) | (from 'n' file length) |
+-------------------------------------------------------------------+
| Repeat for 'n' number of files |
+-------------------------------------------------------------------+
| Message length | Message data |
| (64 bits) | (from message length) |
+-------------------------------------------------------------------+
Status byte
The first bit in the status byte must be 1 and then remaining bits are the custom status bits.
Custom status bit ranges from 0 to 127
Example usage
Server
Here is a simple server implementation with tej-protoc.
Create a new file named server.py
from tej_protoc.server import TPServer
from tej_protoc import protocol
from tej_protoc import callbacks
class MessageCallback(callbacks.ResponseCallback):
def connected(self, client):
builder = protocol.BytesBuilder()
builder.set_message(b'Hello')
protocol.send(client, builder.bytes())
def received(self, files, message):
print('---- Received in server ----')
for file in files:
print(file.name)
print('Message: ', message.decode())
print('---------------------------------')
server = TPServer('localhost', 8000, MessageCallback)
server.listen()
You can also access the client object inside callback methods with self.client.
Your code inside the Callback class is executed everytime when the client connects and
the data is received. Once the client is connected connected method is called. If you want to send data when client
connects, then you can send with protocol.send(client, builder.build()).
To send data from client, you need to build compatible bytes array with BytesBuilder class.
Client
from tej_protoc.client import TPClient
from tej_protoc import protocol
from tej_protoc import callbacks
class ClientCallback(callbacks.ResponseCallback):
def connected(self, client):
builder = protocol.BytesBuilder()
builder.set_message(b'Sending from client')
# To upload file
# builder.add_file('file.txt', open('file.txt', 'rb').read())
protocol.send(client, builder.bytes())
def received(self, files, message):
for file in files:
print(f'Filename: {file.name}')
# Other attributes: file.size, file.data
print(f'Message: {message.decode()}')
def test_client():
try:
client = TPClient('localhost', 8000, ClientCallback)
client.listen()
except Exception as e:
print('error', e)
test_client()
Metadata
Release files for tej-protoc 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tej-protoc-0.2.4.tar.gz | 9.1 kB | Without provenance | Details for tej-protoc-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tej_protoc-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for tej_protoc-0.2.4-py3-none-any.whl |
Total release size: 19.7 kB
Release files / tej-protoc-0.2.4.tar.gz
| Download URL | tej-protoc-0.2.4.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11673507406b5294f40366580579ae9d95ad26813caa5ebfd116461272e87eff
|
|
BLAKE2b-256 checksum How to use checksums |
b4f81862d2830a0f95066822c99534ce3a915e902f13bbb1f835384ecd0d62b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / tej_protoc-0.2.4-py3-none-any.whl
| Download URL | tej_protoc-0.2.4-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc92b1b309b3b1645f612a1de7e67aee300218361822719271112059651b56a5
|
|
BLAKE2b-256 checksum How to use checksums |
a03869ad1c76c717b4efcf70a0a0845d3f023579168fb93ce2e39b6c2e5235d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for tej-protoc 0.2.4
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.