Client-Server threaded TCP connector. This project also uses socket library.
Project description
A module for easy TCP threaded connection.
Example code:
import socket
from sttcp.client import Client
from sttcp.server import Server
# Creating a TCP threaded server
server = Server('localhost', 63552)
# Setting a server handlers
@server.set_handler
def server_handler(addr: tuple, conn: socket.socket, data: bytes):
# All this code executes when somebody connects the TCP server
conn.sendall(data)
# Creating a TCP threaded client
client = Client('localhost', 63552)
# Setting a client handler
@client.set_handler
def client_handler(addr: tuple, conn: socket.socket, data: bytes):
# All this code executes on connection and on receiving response
if data is None:
# data is None when is an initial connection
conn.sendall('Meow'.encode('utf-8'))
else:
# data is not None when client got a response after initial
# connection request
print(f'Recieved "{data.decode("utf-8")}"')
conn.close()
server.mainloop()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 simple_threaded_tcp-1.1.tar.gz.
File metadata
- Download URL: simple_threaded_tcp-1.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e733f0a3f2a18fe762f16b31a43a3d727c8828b32fa24a58ef2572a842105f6b
|
|
| MD5 |
3be554a6f0a2cdd27fa8df2369fa16db
|
|
| BLAKE2b-256 |
c2260f61293d4fc45acdac1734ee92ebedb7c17cf43bf15f6b6a9c885d60b084
|
File details
Details for the file simple_threaded_tcp-1.1-py3-none-any.whl.
File metadata
- Download URL: simple_threaded_tcp-1.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa6e36528d2dab0d31a67ae4042d0f7b4e4fd025ac3ed20aa19dd46d401d8e8b
|
|
| MD5 |
229b2fc194ff8b1d1b6d7ec37894d38b
|
|
| BLAKE2b-256 |
847261079b0c27efc9a0fd5dfadaa91298b3833cef1ed37d77299c2427552cea
|