Please note that this branch is just temporary module of sock module. If the pull request is merged, this branch will be removed.
sock-websocket
Small script to simplify network communication.
Something like telnetlib, but for clean TCP/UDP (no command sequences, \r\n newlines, etc.)
As an alternative, consider pwntools which contains unified interface (tubes) for communications with sockets, processes, etc. See tubes API.
Current development only supports python 3. Old python 2 version is available at the py2 branch.
Installation
$ pip3 install sock-websocket
For development or building from this repository, poetry is needed.
Usage
TCP Client
from sock import *
f = Sock("some.cool.servi.ce:3123", timeout=10)
# or IPv6
f = Sock6("::1 3123", timeout=3)
# or already existing socket
f = Sock.from_socket(some_socket) # or toSock(some_socket)
# or UDP/IPv6
f = SockU6("::1 3123", timeout=3)
# or WebSocket
# For using WebSock, the websocket-client module must be installed (pip install websocket-client).
f = WebSock("ws://localhost:3123")
# wait for prompt (skip banner for example)
# the prompt itself will be skipped (and returned) too
f.read_until("> ", timeout=3) # read_until_re also exists
f.send("flip coin\n")
# skip until regexp
result1 = f.skip_until_re(r"You've got (heads|tails)") # skip_until(str) also exists
# read until also consumes matched part
f.read_until_re(r"You've g[oe]t ") # read_until(str) also exists
# read specific number of bytes
result2 = f.read_nbytes(5)
assert result1 == result2
# alias for f.send(s + "\n")
f.send_line("random please")
# read one packet and flush buffers
print(f.read_one())
# non-blocking read (flush buffers)
print(f.read_one(0))
# read until disconnect
print(f.read_all())
About
Author: hellman
License: MIT License
Metadata
Release files for sock-websocket 0.6.0
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 |
|---|---|---|---|---|
| sock_websocket-0.6.0.tar.gz | 6.0 kB | Without provenance | Details for sock_websocket-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sock_websocket-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for sock_websocket-0.6.0-py3-none-any.whl |
Total release size: 12.1 kB
Release files / sock_websocket-0.6.0.tar.gz
| Download URL | sock_websocket-0.6.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab2f61310d53ba434806476316f6ed6d0592e6f95b0ba48951ba6611bdfc2caf
|
|
BLAKE2b-256 checksum How to use checksums |
730e52bbbeec823acf524342951d6d350d9f9f78199a419b19925e728bd212e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.6.9 Linux/5.4.0-51-generic
|
Release files / sock_websocket-0.6.0-py3-none-any.whl
| Download URL | sock_websocket-0.6.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba9291c38bb24e5ae186402efe93d6b2cfbc1bd7c44069d306cba75b3c0dde0e
|
|
BLAKE2b-256 checksum How to use checksums |
dc98ae9efb6c27d635e1114f8421aae0c8a7494a53ca200c52786aaf5869296b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.6.9 Linux/5.4.0-51-generic
|
Security for sock-websocket 0.6.0
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.