Overview
serversock is a python module to create a server that can accept connection from multiple clients at the same time using multithreading.
Installation
serversock is listed in pypi so the installation is very simple
# in your terminal/CMD run
pip install serversock
Usage
Creating server
# import package
from serversock.serversock import _server
# create class object
serverCTRL = _server(address, port, bufffsize)
The arguments of _server are defined below as
class _server:
def __init__(self, address:str, port: int, buffsize:int = 1024):
"""_server initialization
Args:
address (str): Enter Address like '0.0.0.0'
port (int): Enter port number, example: 8080
buffsize (int, optional): message buffsize. Defaults to 1024.
"""
...
...
After class object creation, start server
# start server
serverCTRL._start(serverfilename, responses)
The arguments of _start are defined below as:
class _server:
...
def _start(self, serverfilename:str, responses:int = 1):
"""start server
Args:
serverfilename (str): serverfilename to save server data
responses (int, optional): Number of response expected from client. Defaults to 1.
"""
...
...
Creating clients
# import _client class from serversock
from serversock.serversock import _client
# create class object
clientCTRL = _client(serveraddress, serverport, serverbufflimit)
The arguments of _client are defined below as:
class _client:
def __init__(self, serveraddress:str, serverport:int, serverbufflimit:int = 1024):
"""_client class initialization
Args:
serveraddress (str): server address like '0.0.0.0'
serverport (int): server port like 8080
serverbufflimit (int, optional): buffersize. Defaults to 1024.
"""
...
...
After that client can perform a bunch of tasks like send a message, sync with the server and disconnect voluntarily.
-
send message and get response in return
- client can send message to the server that the server will save.
# send message clientCTRL._sendToServer(message)
-
sync with the server
- the server sends the complete data that the server has stored to the client in the form of a string.
# sync with the server completedata = clientCTRL._refresh() # this will return a string. # to get the list of lines in the file, do completedata.split('\n') completedata = completedata.split('\n')
-
disconnect voluntarily
# disconnect clientCTRL._disconnect()
Terminal Controls
Check version
# in terminal/CMD, run
serversock -v # or serversock --version
Show help text
# in terminal/CMD run
serversock -h # or serversock --help
Uninstallation
serversock can be uninstalled using pip
# uninstall
pip uninstall serversock
Metadata
Release files for serversock 0.1
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 | |
|---|---|---|---|---|
| serversock-0.1.tar.gz | 7.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| serversock-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / serversock-0.1.tar.gz
| Download URL | serversock-0.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66148fbe23f3851afe7c8137d17f1d88702167bc39e47cd9305b537b12c96241
|
|
BLAKE2b-256 checksum How to use checksums |
074e9d22093440fdf720dec48b8452ae6ef799d9e06934241eac811d59ac77a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.0
|
Release files / serversock-0.1-py3-none-any.whl
| Download URL | serversock-0.1-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d442ba03ef0a65799616e1f7e3d9a0fb04a96c763ab429fcdabf921f5283762d
|
|
BLAKE2b-256 checksum How to use checksums |
9a63e93b9693ed388b2cbe78d88ee4ef209132dc97ceee0c08aa0ffefd2a09af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.0
|
Security for serversock 0.1
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.