Simple socket library for client/server with events management.
Project description
Installation
pip install socketsc
Usage
Simple client and server implementation.
Server
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
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
socketsc-1.9.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file socketsc-1.9.tar.gz.
File metadata
- Download URL: socketsc-1.9.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97378f29f75e8651a57aa6031a9dde04a6cd6d70a9fbef16d88e93749c7283ac
|
|
| MD5 |
df938564eb89cdf161caf959828854b2
|
|
| BLAKE2b-256 |
3b00bb4ad4ab5062f0acf7edabaa08542d4ed2e151502375da67d02e20ecaf1c
|
File details
Details for the file socketsc-1.9-py3-none-any.whl.
File metadata
- Download URL: socketsc-1.9-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02029adcfd50e6af76b688e1d3eb08e7a98947bf47790f07050f47f937e1064b
|
|
| MD5 |
d4711d4f1e8392854ca090d19ab02fb5
|
|
| BLAKE2b-256 |
9d4ed585f8f7c5076765cde5b8d8ac374a6b4cf4335c697ae427628497ada551
|