# 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](https://pypi.org/project/kcp-py/), meaning installing is as simple as running
```sh
pip install kcp.py
```
## Examples
### Asynchronous Server
kcp.py features an implementation of an asynchronous servers using the event loop protocol API.
```py
from kcp.server import Connection
from kcp.server import KCPServerAsync
server = KCPServerAsync(
"127.0.0.1",
9999,
conv_id=1,
)
@server.on_start
async def on_start() -> None:
print("Server started!")
@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 clients using Python's sockets and threads.
```py
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
- [x] Bindings to the C implementation of KCP
- [x] Pythonic API over said C bindings
- [ ] Asynchronous KCP Client
- [x] Synchronous KCP Client
- [x] Asynchronous KCP Server
- [x] Full support for installation through pip
## Credit
kcp.py uses [the official KCP implementation](https://github.com/skywind3000/kcp) behind the scenes.
Raw data
{
"_id": null,
"home_page": "https://github.com/RealistikDash/kcp.py",
"name": "kcp-py",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "kcp,server,client,async,asyncio",
"author": "RealistikDash",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/17/39/95b2d3594450bbfb03547d6d10d56ee2ef3c163514c7fa5f767dcb3e261b/kcp_py-0.1.3.tar.gz",
"platform": null,
"description": "# kcp.py\nPython bindings and networking for the KCP protocol.\n\n## What is KCP?\nKCP is a protocol focusing on low latency data delivery with a guarantee of data delivery. It serves as an alternative to the TCP protocol.\n\n## How to install?\nkcp.py is available on [PyPi](https://pypi.org/project/kcp-py/), meaning installing is as simple as running\n```sh\npip install kcp.py\n```\n\n## Examples\n### Asynchronous Server\nkcp.py features an implementation of an asynchronous servers using the event loop protocol API.\n```py\nfrom kcp.server import Connection\nfrom kcp.server import KCPServerAsync\n\nserver = KCPServerAsync(\n \"127.0.0.1\",\n 9999,\n conv_id=1,\n)\n\n\n@server.on_start\nasync def on_start() -> None:\n print(\"Server started!\")\n\n\n@server.on_data\nasync def on_data(connection: Connection, data: bytes) -> None:\n print(f\"Received data from {connection.address}: {data}\")\n\n\nserver.start()\n```\n\n### Client\nkcp.py also implements a KCP clients using Python's sockets and threads.\n```py\nfrom kcp import KCPClientSync\n\nclient = KCPClientSync(\n \"127.0.0.1\",\n 9999,\n conv_id=1,\n)\n\n\n@client.on_data\ndef handle_data(data: bytes) -> None:\n print(data)\n\n\n@client.on_start\ndef on_start() -> None:\n print(\"Connected to server!\")\n\n while True:\n client.send(b\"Data!\")\n\n\nclient.start()\n```\n\nYou may find more examples in the `examples` directory within the repo.\n\n## Features\n- [x] Bindings to the C implementation of KCP\n- [x] Pythonic API over said C bindings\n- [ ] Asynchronous KCP Client\n- [x] Synchronous KCP Client\n- [x] Asynchronous KCP Server\n- [x] Full support for installation through pip\n\n## Credit\nkcp.py uses [the official KCP implementation](https://github.com/skywind3000/kcp) behind the scenes.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python bindings and networking for the KCP protocol.",
"version": "0.1.3",
"split_keywords": [
"kcp",
"server",
"client",
"async",
"asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ae3eaf13c5e15b53ec9cf699215fa900eb7691451ce5bdf47bcb714c30d4547",
"md5": "cce712968291b21f9aeed343079ccb0f",
"sha256": "dfd33d2d39969d130b47eb0982cc815f708fa4bc42bd6bde8b48c1360f1bf394"
},
"downloads": -1,
"filename": "kcp_py-0.1.3-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "cce712968291b21f9aeed343079ccb0f",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 61136,
"upload_time": "2023-01-31T20:09:25",
"upload_time_iso_8601": "2023-01-31T20:09:25.166094Z",
"url": "https://files.pythonhosted.org/packages/7a/e3/eaf13c5e15b53ec9cf699215fa900eb7691451ce5bdf47bcb714c30d4547/kcp_py-0.1.3-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "173995b2d3594450bbfb03547d6d10d56ee2ef3c163514c7fa5f767dcb3e261b",
"md5": "8af249de6ee41cf97971a07874e3ad2f",
"sha256": "c4113dffd5b8f0501756d9932fc00a7ed2ca130a3732908f96aea29ea650ffa9"
},
"downloads": -1,
"filename": "kcp_py-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "8af249de6ee41cf97971a07874e3ad2f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 20837,
"upload_time": "2023-01-31T20:09:27",
"upload_time_iso_8601": "2023-01-31T20:09:27.434642Z",
"url": "https://files.pythonhosted.org/packages/17/39/95b2d3594450bbfb03547d6d10d56ee2ef3c163514c7fa5f767dcb3e261b/kcp_py-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-31 20:09:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "RealistikDash",
"github_project": "kcp.py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "kcp-py"
}