Skip to main content

Structured Socket

A simple module to encapsulate the built-in socket with struct.pack so that the amount of data received can be forseen by the receiver to prevent sticking packets.

Repository: https://github.com/origamizyt/StructuredSocket (I believe that you can understand the mechanisms without the source code.)

Installation

This module is available on PyPI.

pip install structsock

Or you can install from source .tar.gz either.

python setup.py install

Usage

The exposed interfaces in this module is pretty the same as the built-in module socket, only replacing socket.socket with StructuredSocket:

# server side
from structsock import StructuredSocket

s = StructuredSocket()
s.bind(('0.0.0.0', 5000))
s.listen(5)
c, addr = s.accept()
c.send(b'data')
c.close()
s.close()

Note that the client socket returned is also a instance of StructuredSocket.

# client side
from structsock import StructuredSocket

c = StructuredSocket()
c.connect(('127.0.0.1', 5000))
data = c.recv() # different, no bufsize
print(data.decode())
c.close()

Metadata

Release files for structsock 1.2.0

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

Source distribution (sdist)

Source distribution for structsock 1.2.0
File Size Uploaded
structsock-1.2.0.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for structsock 1.2.0
File Interpreter ABI Platform
structsock-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.3 kB

Release files / structsock-1.2.0.tar.gz

Download URL structsock-1.2.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
207702f47aa00d850bb0d2d056b15f0df1568875699077033abcd082dcb610ea
BLAKE2b-256 checksum
How to use checksums
dec6e9f66a5214e4331ecb3c7088ac6d867056279a420c8f16206080ca2607e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release files / structsock-1.2.0-py3-none-any.whl

Download URL structsock-1.2.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3167b7399b96ba2fdc0bea31f9621db2487b43e2cfb96acf23384480c7632718
BLAKE2b-256 checksum
How to use checksums
cb7733908e923f3d8193b35f47f7d49c4598c5afa2587bb0b9f5bcb992eafe78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

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