ABOUT
Python package which allows creation of simple servers and clients for communication with sockets. Supports both Python2 and Python3.
Version: 1.0.0
USAGE
- To create a server: Depending on your Python version, import the Server class from the appropriate server module, subclass it and override its act_on() method which describes what it should do when it receives a request, and returns a string response. Finally, create a Server object and call its listen() method.
- To create a client: Depending on your Python version, import the Client class from the appropriate client module, create a Client object and call its poll_server() method. You can then make use of the response it returns as required.
By default, a Python2 client will poll the default Python3 server while a Python3 client will poll the default Python2 server (unlike in the examples below).
EXAMPLES
# Test server with Python2:
from sockets.python2.server import Server
class MyServer(Server):
def act_on(self, data, addr):
# Do something with data (in bytes) and return a string.
return data
server = MyServer(listening_address=('127.0.0.1', 11112))
server.listen()
# Test client with Python2. Polls the Python2 server.
from sockets.python2.client import Client
client = Client()
response, addr = client.poll_server("Hello world", server=('127.0.0.1', 11112))
print response, addr
# Test server with Python3:
from sockets.python3.server import Server
class MyServer(Server):
def act_on(self, data, addr):
# Do something with data (in bytes) and return a string.
return data.decode()
server = MyServer(listening_address=('127.0.0.1', 11113))
server.listen()
# Test client with Python3. Polls the Python3 server.
from sockets.python3.client import Client
client = Client()
response, addr = client.poll_server("Hello world", server=('127.0.0.1', 11113))
print(response, addr)
CONTRIBUTING AUTHORS
Ehiorobo Evans (2018).
Metadata
Release files for sockets 1.0.0
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 | Actions |
|---|---|---|---|---|
| sockets-1.0.0.tar.gz | 2.5 kB | Without provenance | Details for sockets-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sockets-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for sockets-1.0.0-py3-none-any.whl |
Total release size: 7.0 kB
Release files / sockets-1.0.0.tar.gz
| Download URL | sockets-1.0.0.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d5691402d3da39c9ef6330647d847b0bed93a4ce8b23bf1a18133e2dcbb5c8d
|
|
BLAKE2b-256 checksum How to use checksums |
c2a76bc7eeefb624e03e5a34c2c0d8eff6525487b1af0ccfd62d0f83a62a5400
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / sockets-1.0.0-py3-none-any.whl
| Download URL | sockets-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdb78b0f37b78adadedcc55cdd73c61aacbeb0f00c4c551f1b60f1463457c90b
|
|
BLAKE2b-256 checksum How to use checksums |
cd84bd124c5d3c012de593c45c7f0208615c73493859bbd5389e1403e311d387
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sockets 1.0.0
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.