!["socketsc"](https://i.imgur.com/aVhWeoh.png)
[![License](https://img.shields.io/pypi/l/socketsc)](https://pypi.org/project/socketsc/)
[![Version](https://img.shields.io/pypi/v/socketsc)](https://pypi.org/project/socketsc/)
[![Python](https://img.shields.io/pypi/pyversions/socketsc)](https://pypi.org/project/socketsc/)
[![Documentation Status](https://readthedocs.org/projects/socketsc/badge/?version=latest)](https://socketsc.readthedocs.io/en/latest/?badge=latest)
[![Downloads](https://img.shields.io/pypi/dm/socketsc)](https://pypi.org/project/socketsc/)
[![Issues](https://img.shields.io/gitlab/issues/open/dan5py/socketsc)](https://gitlab.com/dan5py/socketsc/-/issues)
## Installation
```bash
pip install socketsc
```
## Usage
Simple client and server implementation.
### Server
```python
import socketsc
server = socketsc.SocketServer(("localhost", 8080), address_family=socketsc.AF_INET, sock_type=socketsc.SOCK_TCP)
print("Server listening on port 8080")
def on_question(socket: socketsc.ServerSocketWrapper, data):
print(f"Received {data} from {socket.client_address}")
socket.emit("answer", "1")
server.on("question", on_question)
server.serve()
```
### Client
```python
import socketsc
server_address = ("localhost", 8080)
sock = socketsc.SocketClient(server_address, address_family=socketsc.AF_INET, sock_type=socketsc.SOCK_TCP)
def on_answer(conn: socketsc.SocketClient, data):
print(f"Server responded with {data}")
sock.emit("question", "0")
sock.on("answer", on_answer)
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/dan5py/socketsc",
"name": "socketsc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.0",
"maintainer_email": "",
"keywords": "server client socket event tcp",
"author": "Dan5py",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/3b/00/bb4ad4ab5062f0acf7edabaa08542d4ed2e151502375da67d02e20ecaf1c/socketsc-1.9.tar.gz",
"platform": null,
"description": "![\"socketsc\"](https://i.imgur.com/aVhWeoh.png)\r\n\r\n[![License](https://img.shields.io/pypi/l/socketsc)](https://pypi.org/project/socketsc/)\r\n[![Version](https://img.shields.io/pypi/v/socketsc)](https://pypi.org/project/socketsc/)\r\n[![Python](https://img.shields.io/pypi/pyversions/socketsc)](https://pypi.org/project/socketsc/)\r\n[![Documentation Status](https://readthedocs.org/projects/socketsc/badge/?version=latest)](https://socketsc.readthedocs.io/en/latest/?badge=latest)\r\n[![Downloads](https://img.shields.io/pypi/dm/socketsc)](https://pypi.org/project/socketsc/)\r\n[![Issues](https://img.shields.io/gitlab/issues/open/dan5py/socketsc)](https://gitlab.com/dan5py/socketsc/-/issues)\r\n\r\n## Installation\r\n\r\n```bash\r\npip install socketsc\r\n```\r\n\r\n## Usage\r\n\r\nSimple client and server implementation.\r\n\r\n### Server\r\n\r\n```python\r\nimport socketsc\r\n\r\nserver = socketsc.SocketServer((\"localhost\", 8080), address_family=socketsc.AF_INET, sock_type=socketsc.SOCK_TCP)\r\n\r\nprint(\"Server listening on port 8080\")\r\n\r\ndef on_question(socket: socketsc.ServerSocketWrapper, data):\r\n print(f\"Received {data} from {socket.client_address}\")\r\n socket.emit(\"answer\", \"1\")\r\n\r\nserver.on(\"question\", on_question)\r\nserver.serve()\r\n```\r\n\r\n### Client\r\n\r\n```python\r\nimport socketsc\r\n\r\nserver_address = (\"localhost\", 8080)\r\nsock = socketsc.SocketClient(server_address, address_family=socketsc.AF_INET, sock_type=socketsc.SOCK_TCP)\r\n\r\n\r\ndef on_answer(conn: socketsc.SocketClient, data):\r\n print(f\"Server responded with {data}\")\r\n\r\n\r\nsock.emit(\"question\", \"0\")\r\nsock.on(\"answer\", on_answer)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple socket library for client/server with events management.",
"version": "1.9",
"split_keywords": [
"server",
"client",
"socket",
"event",
"tcp"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "d4711d4f1e8392854ca090d19ab02fb5",
"sha256": "02029adcfd50e6af76b688e1d3eb08e7a98947bf47790f07050f47f937e1064b"
},
"downloads": -1,
"filename": "socketsc-1.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d4711d4f1e8392854ca090d19ab02fb5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.0",
"size": 8957,
"upload_time": "2022-12-04T10:42:04",
"upload_time_iso_8601": "2022-12-04T10:42:04.701396Z",
"url": "https://files.pythonhosted.org/packages/9d/4e/d585f8f7c5076765cde5b8d8ac374a6b4cf4335c697ae427628497ada551/socketsc-1.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "df938564eb89cdf161caf959828854b2",
"sha256": "97378f29f75e8651a57aa6031a9dde04a6cd6d70a9fbef16d88e93749c7283ac"
},
"downloads": -1,
"filename": "socketsc-1.9.tar.gz",
"has_sig": false,
"md5_digest": "df938564eb89cdf161caf959828854b2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.0",
"size": 7793,
"upload_time": "2022-12-04T10:42:06",
"upload_time_iso_8601": "2022-12-04T10:42:06.784877Z",
"url": "https://files.pythonhosted.org/packages/3b/00/bb4ad4ab5062f0acf7edabaa08542d4ed2e151502375da67d02e20ecaf1c/socketsc-1.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-04 10:42:06",
"github": false,
"gitlab": true,
"bitbucket": false,
"gitlab_user": "dan5py",
"gitlab_project": "socketsc",
"lcname": "socketsc"
}