kcp.py
Python bindings and networking for the KCP protocol.
What is KCP?
KCP is a protocol focusing on low latency data delivery with a guarantee of data delivery. It serves as an alternative to the TCP protocol.
How to install?
kcp.py is available on PyPi, meaning installing is as simple as running
pip install kcp
Examples
Just the raw connection
While kcp.py features a diverse set of pre-implemented uses of KCP (see below), it also allows you to directly manage your KCP connections. Here is an example using two independent connections locally.
from kcp import KCP
# Create two connections using the same conversation ID.
kcp1 = KCP(
conv_id=1,
)
kcp2 = KCP(
conv_id=1,
)
# Update their timing information.
kcp1.update()
kcp2.update()
# Set each connection to send data to the other one (usually this would go through some network layer, but
# for the purpose of the example we do this).
@kcp1.outbound_handler
def send_kcp1(_, data: bytes) -> None:
kcp2.receive(data)
@kcp2.outbound_handler
def send_kcp2(_, data: bytes) -> None:
kcp1.receive(data)
# Enqueue data to be sent and send it off.
kcp1.enqueue(b"Hello, world!")
kcp1.flush()
print(kcp2.get_received()) # b"Hello, world!"
Asynchronous Server
kcp.py features an implementation of an asynchronous server using the event loop protocol API.
from kcp.server import Connection
from kcp.server import KCPServerAsync
# Create the initial server instance.
server = KCPServerAsync(
"127.0.0.1",
9999,
conv_id=1,
no_delay=True,
)
# Ability to set performance options after initialisation.
server.set_performance_options(
update_interval=10,
)
# Ran when the server starts.
@server.on_start
async def on_start() -> None:
print("Server started!")
# Ran when a connection is made.
@server.on_data
async def on_data(connection: Connection, data: bytes) -> None:
print(f"Received data from {connection.address}: {data}")
server.start()
Client
kcp.py also implements a KCP client using Python's sockets and threads.
from kcp import KCPClientSync
client = KCPClientSync(
"127.0.0.1",
9999,
conv_id=1,
)
@client.on_data
def handle_data(data: bytes) -> None:
print(data)
@client.on_start
def on_start() -> None:
print("Connected to server!")
while True:
client.send(b"Data!")
client.start()
You may find more examples in the examples directory within the repo.
Features
- Bindings to the C implementation of KCP
- Pythonic API over said C bindings
- Asynchronous KCP Client
- Synchronous KCP Client
- Asynchronous KCP Server
- Full support for installation through pip
Credit
kcp.py uses the official KCP implementation behind the scenes.
Metadata
Release files for kcp 0.1.6
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 |
|---|---|---|---|---|
| kcp-0.1.6.tar.gz | 22.5 kB | Without provenance | Details for kcp-0.1.6.tar.gz |
Built distributions (wheels)
Total release size: 3.3 MB
Release files / kcp-0.1.6.tar.gz
| Download URL | kcp-0.1.6.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e3632509119bd6a24599ee043e21ef6842675413a41720c526d14896357afc4
|
|
BLAKE2b-256 checksum How to use checksums |
3c8218cff233d7a848788450ae2a4341d5f54bb19afb0d5dd3a06be76ebca953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Darwin/23.6.0
|
Release files / kcp-0.1.6-cp313-cp313-win_amd64.whl
| Download URL | kcp-0.1.6-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 74.5 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3c1b2f90f15e55ec76b929dd8d29bed4b4eadc234addefd2b8be5f0f3acf822d
|
|
BLAKE2b-256 checksum How to use checksums |
24bd17c07c4b142ad3a6c8d236ef5ff23951516ff766ee524ec675b5b5c34202
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.1 Windows/2022Server
|
Release files / kcp-0.1.6-cp313-cp313-manylinux_2_39_x86_64.whl
| Download URL | kcp-0.1.6-cp313-cp313-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 333.0 kB |
| Tags | CPython 3.13 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
ee78627a02e908c225c669b7cc8654b825296fb8133f2a1556f633b72e9dad3e
|
|
BLAKE2b-256 checksum How to use checksums |
eb5a0c06c2c7a4cdafe32ffa7bd7820959e30b1d8c5055f3dcf049118c693180
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.1 Linux/6.8.0-1017-azure
|
Release files / kcp-0.1.6-cp313-cp313-macosx_14_0_arm64.whl
| Download URL | kcp-0.1.6-cp313-cp313-macosx_14_0_arm64.whl |
|---|---|
| Size | 133.8 kB |
| Tags | CPython 3.13 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c2327d597628c4d654ff7d7663701f0de7587f4c840796eaff096fd31ae004e9
|
|
BLAKE2b-256 checksum How to use checksums |
bcefb7f1663992ea73a92c67099c6d61bbfd72bcaee1499b80bb06dfa756a513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.13.1 Darwin/23.6.0
|
Release files / kcp-0.1.6-cp312-cp312-win_amd64.whl
| Download URL | kcp-0.1.6-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 75.0 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e742cbc3052f4f6b986371ad47e46e386093b7633228280c09180a0b56f40c74
|
|
BLAKE2b-256 checksum How to use checksums |
1a02752dc922e2c75080918e1158a7747a27f64ad622c964b430c2d6e16c2039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Windows/2022Server
|
Release files / kcp-0.1.6-cp312-cp312-manylinux_2_39_x86_64.whl
| Download URL | kcp-0.1.6-cp312-cp312-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 331.1 kB |
| Tags | CPython 3.12 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
005a5960317762afdbddd701c334e2a1aaadc27be31cdfd8fc3d0827265f1b1b
|
|
BLAKE2b-256 checksum How to use checksums |
8a9fd978a36a026af425ee18b18d0997288c1148c3c90f888e8fed26c0829ad3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Linux/6.8.0-1017-azure
|
Release files / kcp-0.1.6-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | kcp-0.1.6-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 135.5 kB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
512a92d324a277b0b095a611a1e4d42680e9524e4136f97b105417f5f17799d7
|
|
BLAKE2b-256 checksum How to use checksums |
b6cefac912517be962a5bc5bc934e834d9691b85ee0b853c78dac585e7753a87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Darwin/23.6.0
|
Release files / kcp-0.1.6-cp311-cp311-win_amd64.whl
| Download URL | kcp-0.1.6-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 76.1 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6a481bfc1e595cb9e6c7c8b33673c032b455beccb9794ebc6dd62be841314b6e
|
|
BLAKE2b-256 checksum How to use checksums |
590af57e16ad03998c381015c50ebcac67e1a15e891bdaa06f2c6c62a81bcb1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.11.9 Windows/10
|
Release files / kcp-0.1.6-cp311-cp311-manylinux_2_39_x86_64.whl
| Download URL | kcp-0.1.6-cp311-cp311-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 350.7 kB |
| Tags | CPython 3.11 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
da4aa6acbdfdfd25a64841b7b13e8063098cd0b613d8475ccf3b7f22dfd22d64
|
|
BLAKE2b-256 checksum How to use checksums |
eac6a25c139498666adb8b09968492ffe9e6b4f914e2db79164dca572c81550e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.11.11 Linux/6.8.0-1017-azure
|
Release files / kcp-0.1.6-cp311-cp311-macosx_14_0_arm64.whl
| Download URL | kcp-0.1.6-cp311-cp311-macosx_14_0_arm64.whl |
|---|---|
| Size | 137.4 kB |
| Tags | CPython 3.11 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d5f95fe061a6b611e74a43bc0b038403a5c4e60e3fd8f321e089916a8f82f3e5
|
|
BLAKE2b-256 checksum How to use checksums |
f305d21d2ebd0daf76893727f4afd68423e11c05f01809307d15059724c0ca28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.11.9 Darwin/23.6.0
|
Release files / kcp-0.1.6-cp310-cp310-win_amd64.whl
| Download URL | kcp-0.1.6-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 76.0 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d2c973b58504a43a1569d4ce9a7acd7a61fbb78aaef8ba735f00d497e53bda28
|
|
BLAKE2b-256 checksum How to use checksums |
8b0e8b214f98fafc1bdda953c4c3f3197c0e5495eece64ddf97dce6c1a0205c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.10.11 Windows/10
|
Release files / kcp-0.1.6-cp310-cp310-manylinux_2_39_x86_64.whl
| Download URL | kcp-0.1.6-cp310-cp310-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 327.2 kB |
| Tags | CPython 3.10 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
a9e974a11014043486b05ab88ea4b460820f17ae6f8f5ea1223cd74603e6ddd7
|
|
BLAKE2b-256 checksum How to use checksums |
c1b894e2e1fb4eacce717af0a891156627a905da393d7d235148da1c86ed9340
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.10.15 Linux/6.8.0-1017-azure
|
Release files / kcp-0.1.6-cp310-cp310-macosx_14_0_arm64.whl
| Download URL | kcp-0.1.6-cp310-cp310-macosx_14_0_arm64.whl |
|---|---|
| Size | 136.9 kB |
| Tags | CPython 3.10 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7a7d49e22f19ab7fedaa1d2f6790865fd79172ce5623c385e32c39b0e6fd9d9d
|
|
BLAKE2b-256 checksum How to use checksums |
583e70c8fd49739f388c9a0453264bc915d8a7e0bb5be146686d240ad2bd9a00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.10.11 Darwin/23.6.0
|
Release files / kcp-0.1.6-cp39-cp39-win_amd64.whl
| Download URL | kcp-0.1.6-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 76.1 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
70abddc571eee49e20b30a88139e2abc3202edd59b6d36cd6f29127004bdedf1
|
|
BLAKE2b-256 checksum How to use checksums |
8cb16d2d2a232b4ce7ffdb297f5404a4204baafcdefda0dfe168fdc19dba3ce6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.9.13 Windows/10
|
Release files / kcp-0.1.6-cp39-cp39-manylinux_2_39_x86_64.whl
| Download URL | kcp-0.1.6-cp39-cp39-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 328.8 kB |
| Tags | CPython 3.9 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
d8aa34931521ebc791e662b9a538c1c5f82c81c8b3a73c4b4bb7f72b11fde4c4
|
|
BLAKE2b-256 checksum How to use checksums |
3a9de150f9bf2dfb010fec60aef501c27cc60107f8627fceefb6c7270c42f38b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.9.20 Linux/6.8.0-1017-azure
|
Release files / kcp-0.1.6-cp39-cp39-macosx_14_0_arm64.whl
| Download URL | kcp-0.1.6-cp39-cp39-macosx_14_0_arm64.whl |
|---|---|
| Size | 137.4 kB |
| Tags | CPython 3.9 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6e8cf8ef2e8094c5e4791540352aba0802bc65d8fb2f565659d86e53939b8689
|
|
BLAKE2b-256 checksum How to use checksums |
984b3eac0c8bf7c59086a5d44144446fe163c6ec59e615c63de2a502164ea7b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.9.13 Darwin/23.6.0
|
Release files / kcp-0.1.6-cp38-cp38-win_amd64.whl
| Download URL | kcp-0.1.6-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 76.3 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9c568788168f95f746137aaab2e4c576906b11ce622543a4b2b6fca3ff92bfd1
|
|
BLAKE2b-256 checksum How to use checksums |
1797e7e34073914d9e703bf58e890016ffbc0b90e887d86c4918dd8c24e80014
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.8.10 Windows/10
|
Release files / kcp-0.1.6-cp38-cp38-manylinux_2_39_x86_64.whl
| Download URL | kcp-0.1.6-cp38-cp38-manylinux_2_39_x86_64.whl |
|---|---|
| Size | 333.8 kB |
| Tags | CPython 3.8 Linux glibc 2.39+ x86-64 |
|
SHA-256 checksum How to use checksums |
f0c69b253f02614d8aeff2e3826370b38046a3a9af9fdce33a7114fbe977ec74
|
|
BLAKE2b-256 checksum How to use checksums |
c9271ccf1ac497c7845dee827a996a5c658ec0506c6c72342b9f79675b7c5cca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.8.18 Linux/6.8.0-1017-azure
|
Release files / kcp-0.1.6-cp38-cp38-macosx_14_0_arm64.whl
| Download URL | kcp-0.1.6-cp38-cp38-macosx_14_0_arm64.whl |
|---|---|
| Size | 138.8 kB |
| Tags | CPython 3.8 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0a46d42de2161893a6aece95417ac01cef8a87e1b5ee0619151797654ad6a0ca
|
|
BLAKE2b-256 checksum How to use checksums |
90477d9fdf2f1536300f3513778577e1b7fd673924b4d11b174ac69fd1b66b6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.8.10 Darwin/23.6.0
|
Security for kcp 0.1.6
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.